Hi Guys,
Is there a way in analytics I can use GROUP BY without using aggregate function ?
Here is my location document:
[ { "location": "location::0032", "oldRank": { "name": "D-2371", "level": "D", "position": 2371 }, "territory": "territory::1000" }, { "location": "location::0033", "oldRank": { "name": "D-2376", "level": "D", "position": 2376 }, "territory": "territory::1000" }, { "location": "location::2233", "oldRank": { "name": "C-1376", "level": "C", "position": 1376 }, "territory": "territory::0007" }, { "location": "location::0001", "oldRank": { "name": "C-1376", "level": "C", "position": 1376 }, "territory": "territory::0004" }
My expected result would be like this:
[ { "territory": "territory::1000", "locations": [ { "location": "location::0032", "oldRank": { "name": "D-2371", "level": "D", "position": 2371 } }, { "location": "location::0033", "oldRank": { "name": "D-2376", "level": "D", "position": 2376 } } ] }, { "territory": "territory::0007", "locations": [ { "location": "location::2233", "oldRank": { "name": "C-1376", "level": "C", "position": 1376 } } ] }, { "territory": "territory::0004", "locations": [ { "location": "location::0001", "oldRank": { "name": "C-1376", "level": "C", "position": 1376 } } ] } ]
My Initial query:
SELECT meta(l).`id` as location, l.`rank` as oldRank, l.territory as territory FROM company_analytics.`locations` l WHERE l.`status` = 'active'
Thanks guys,