Q: ArangoDB sum by groups I have little problem with ArangoDB query. In postgres i did it quick and with no problems:
SELECT SUM(x) from table GROUP BY
  case
   when age < 18 then 'Under 18'
   when age between 18 and 24 then '18-24'
   when age between 25 and 67 then '25-67'
   when age between 68 and 100 then '68-100'
 END

I want to compare time for this execution in postgres and arango but... i have no idea how it should look like in arango. 
There's posibility to create few group (FILTER + COLLECT AGGREGATE s = SUM(set return from FILTER)) in one LOOP?
Any ideas?

A: The following should work in AQL:
FOR doc IN collection
  COLLECT group = (doc.age < 18 ? "Under 18" : 
                   (doc.age >= 18 && doc.age <= 24 ? "18-24" : 
                    (doc.age >= 25 && doc.age <= 67 ? "25-67" : 
                     (doc.age >= 68 && doc.age <= 100 ? "68-100" : "other" ))))
  AGGREGATE s = SUM(doc.x)
  RETURN { group, s }

