I have data stored in JSON arrays for each row in a PostgreSQL table like so:
id data
-------------------------------------------------
1 [{"a": 1, "b": 2}, {"a": 3, "b":2}]
2 [{"a": 5, "b": 8}, {"a": 9, "b":0}]
How can I get the sum of specific keys in the recordsets grouped by id? Here is an example of the desired result set:
id a b
-------------------------------------------------
1 4 4
2 14 8
Update:
I should also mention that the data column is a jsonb data type.