How to create a query about users in a Drupal Commons group including their location (State)?
To create such query (and report) you may want to look at the Forena module. You would use its report writing features (such as its WYSIWYG report writer and/or it's query builder) to first create a report that fits your needs. The result of it could be a tabular output and/or graph. After the report content matches the specifications, you could save it as (e.g.) a CSV file.

Here is a quote from one of the Forena community docu pages, i.e. Reasons for considering Forena:


  Reports created by Forena (combined with SVGGraph and mPDF) can be
  saved (exported) as PDF documents with embedded graphs. Other
  supported formats for saving a report are CSV, XLS, DOC, HTML, etc.


Similar samples


Refer to this online example in the Forena demo site for a report that is fairly similar to the kind of (tabular) report you could (easily) create:


Using Forena's Query builder you would create the required SQL statement (if you'd rather want to write the SQL with your favorite SQL editor that's another option).
Using forena's WYSIWYG report writer you would develop your custom report (if you'd rather want to write that report with your favorite XHTML editor that's another option).


Some more details about the sample report mentioned above:


Use the "Parameters" pulldown option, to select any other state.
Note the PDF hyperlink: using that link, you'll get a PDF version of that report. When creating such report, you could as well ask for other (or additional) report export formats, one of them is CSV (or XLS, DOC, HTML, ...). This is how the CSV equivalent version of that sample report looks like.

The Master Summary with drill down sample report demonstrates how you can also "link" various reports together (while it also shows some of the charting features of Forena). Click on either any of those bars in the chart, or on the total-hyperlink in tabular report below the chart. Doing so will bring you to the report "for the selected state" (= the first sample report mentioned above).


Direct access to data blocks

All data blocks are accessible directly via their url also, provided you have permission to access that block. Here are a few samples of that, for the sample report located at /reports/sample.states:


in XML format (= demo with anonymous access).
in JSON format (= demo with anonymous access).
in XML format (= demo without anonymous access).
in JSON format (= demo without anonymous access).


More info about supported export formats

Refer to my answer to "How to add a link to the CSV download to my module page, for a report created with Forena?" for more details about supported export formats.

Video tutorials

The Forena Video demos and tutorials contain quite some links to live demos. They should help a lot to get you started.

Disclosure: I'm a co-maintainer of Forena.