How can I write this in elasticsearch:
SELECT avg(sum)
FROM (
SELECT sum(rev) as sum
FROM table
GROUP BY user_id
)
How can I write this in elasticsearch:
SELECT avg(sum)
FROM (
SELECT sum(rev) as sum
FROM table
GROUP BY user_id
)
If ES version you are using is 2.x use Avg Bucket Aggregation
Hope it helps