## sighup (r...@sighup.eu):

> How can I extract the value of the 'items' key either as two rows and or 
> a sum of both.

select id, jsonb_array_elements(markers)->>'items' from data;
And as jsonb_array_elements() returns a setof jsonb:
with tab(id, items) as (
  select id, (jsonb_array_elements(markers)->>'items')::integer from d
) select id, sum(items) from tab group by id;

Regards,
Christoph

-- 
Spare Space


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to