Query
{
"group": {
"into": "g",
"by": "p.category"
},
"as": "p",
"from": "Products",
"select": {
"category": "g.key",
"mostExpensiveProducts": {
"where": "p.unitPrice == g.max(p.unitPrice)",
"as": "p",
"from": "g",
"select": "p"
}
}
}
Results
[
{
"category": "Beverages",
"mostExpensiveProducts": [
{
"category": "Beverages",
"unitsInStock": 17,
"productName": "C\u00c3\u00b4te de Blaye",
"unitPrice": 263.5,
"productId": 38
}
]
},
{
"category": "Condiments",
"mostExpensiveProducts": [
{
"category": "Condiments",
"unitsInStock": 24,
"productName": "Vegie-spread",
"unitPrice": 43.9,
"productId": 63
}
]
},
{
"category": "Produce",
"mostExpensiveProducts": [
{
"category": "Produce",
"unitsInStock": 20,
"productName": "Manjimup Dried Apples",
"unitPrice": 53.0,
"productId": 51
}
]
},
{
"category": "Meat/Poultry",
"mostExpensiveProducts": [
{
"category": "Meat/Poultry",
"unitsInStock": 0,
"productName": "Th\u00c3\u00bcringer Rostbratwurst",
"unitPrice": 123.79,
"productId": 29
}
]
},
{
"category": "Seafood",
"mostExpensiveProducts": [
{
"category": "Seafood",
"unitsInStock": 42,
"productName": "Carnarvon Tigers",
"unitPrice": 62.5,
"productId": 18
}
]
},
{
"category": "Dairy Products",
"mostExpensiveProducts": [
{
"category": "Dairy Products",
"unitsInStock": 79,
"productName": "Raclette Courdavault",
"unitPrice": 55.0,
"productId": 59
}
]
},
{
"category": "Confections",
"mostExpensiveProducts": [
{
"category": "Confections",
"unitsInStock": 40,
"productName": "Sir Rodney's Marmalade",
"unitPrice": 81.0,
"productId": 20
}
]
},
{
"category": "Grains/Cereals",
"mostExpensiveProducts": [
{
"category": "Grains/Cereals",
"unitsInStock": 2,
"productName": "Gnocchi di nonna Alice",
"unitPrice": 38.0,
"productId": 56
}
]
}
]