Query a list of field values of a node in drupal 7
Consider using the Forena module, it comes with all sorts of reporting features. And all sorts of hooks if you want to use them in your own custom modules.
Here is an excerpt from its Community documentation:

Forena Reports is built of the idea of using SQL to get data out of a database and use XHTML and CSS to format it into web reports.
It is designed to leverage existing knowledge of HTML, CSS, SQL and JavaScript to help you create rich interactive web reports.

Disclosure: I'm a co-maintainer of Forena,
I hope this does not violate the site's policy on self-promotion.