Custom API, running an SQL query on the database

So it’s reached the point where we need to query the database in order to get the information we need (look at previous posts), we have studied the database and figured out the query in order to do this and have run it on the data to make sure. I know we are able to create our own custom report / api methods, but is it possible to do a query to the database through this?

I’d also like to know this. Did you manage to solve your problem?