Search code examples
socratasoda

Socrata API How to return List of values from Group by


I am able to do a group by query like this

https://data.sfgov.org/resource/wwmu-gmzc.json?$query=select%20title,%20release_year,%20locations,%20COUNT(title)%20group%20by%20release_year,%20title,%20locations%20order%20by%20title%20desc

But unable to return a list of values for a single group by. say group by release_year or title or locations.

For example, when I use group by release_year, I'd like to return the following

    {
         "release_year": "1949",
         "entires": [
              {
                    "title": "blh blh"
                    "locations":  "soma"
              }               
          ]
    }

Do you know how i can do this?


Solution

  • The $group parameter is used for aggregation, not for nesting like you're trying to do. There isn't a SoQL parameter or function that will change the structure of the JSON response like you're looking for.

    If I were you, I'd look at $order-ing by release_year and then construct the nesting you're looking for in code.