I have this query which works:
select point_delivery_number, year(time - -120m) as year, month(time - -120m) - 1 as month, SUM(consumption) as value from "energy_datapoints"."formatted_raw"
WHERE point_delivery_number in ('AT523452345sadf345', 'AT2341234asdf5234452341243')
GROUP BY 1,2,3
ORDER BY year, month
LIMIT 24
It outputs this result:
I want to group this by its point_delivery_number
Result should be
point_delivery_number | year | data
------------------------------------------------------
AT23... | 2021 | [216.54, 202.77, 210.4]
------------------------------------------------------
At523.. | 2021 | [489.84, 423.6, ...]
I tried it with ARRAY_AGG
select point_delivery_number, year(time - -120m) as year, month(time - -120m) - 1 as month, ARRAY_AGG(SUM(consumption)) as data from "energy_datapoints"."formatted_raw"
WHERE point_delivery_number in ('AT523452345sadf345', 'AT2341234asdf5234452341243')
GROUP BY 1,2,3
ORDER BY year, month
LIMIT 24
But it says:
Cannot nest aggregations inside aggregation 'ARRAY_AGG'
I am using aws timestream database, so there are some limitations. Some functions do not even exist.