JSON/q

A JSON-based data access specification

Query

{
  "group": {
    "into": "g", 
    "by": "p.category"
  }, 
  "as": "p", 
  "from": "Products", 
  "select": {
    "category": "g.key", 
    "averagePrice": "g.average(p.unitPrice)"
  }
}

Results

[
  {
    "category": "Beverages", 
    "averagePrice": 37.979166666666664
  }, 
  {
    "category": "Condiments", 
    "averagePrice": 23.0625
  }, 
  {
    "category": "Produce", 
    "averagePrice": 32.37
  }, 
  {
    "category": "Meat/Poultry", 
    "averagePrice": 54.00666666666667
  }, 
  {
    "category": "Seafood", 
    "averagePrice": 20.6825
  }, 
  {
    "category": "Dairy Products", 
    "averagePrice": 28.73
  }, 
  {
    "category": "Confections", 
    "averagePrice": 25.16
  }, 
  {
    "category": "Grains/Cereals", 
    "averagePrice": 20.25
  }
]