JSON/q

A JSON-based data access specification

Query

{
  "group": {
    "into": "g", 
    "by": "p.category"
  }, 
  "as": "p", 
  "from": "Products", 
  "select": {
    "category": "g.key", 
    "productCount": "g.count()"
  }
}

Results

[
  {
    "category": "Beverages", 
    "productCount": 12
  }, 
  {
    "category": "Condiments", 
    "productCount": 12
  }, 
  {
    "category": "Produce", 
    "productCount": 5
  }, 
  {
    "category": "Meat/Poultry", 
    "productCount": 6
  }, 
  {
    "category": "Seafood", 
    "productCount": 12
  }, 
  {
    "category": "Dairy Products", 
    "productCount": 10
  }, 
  {
    "category": "Confections", 
    "productCount": 13
  }, 
  {
    "category": "Grains/Cereals", 
    "productCount": 7
  }
]