PostgreSQL
 sql >> Datenbank >  >> RDS >> PostgreSQL

Postgres:Erweitern Sie die JSON-Spalte in Zeilen

select id,
    (details ->> 'json1')::int as json1,
    (details ->> 'json2')::int as json2
from (
    select id, json_array_elements(details) as details
    from things
) s
;
 id | json1 | json2 
----+-------+-------
  1 |   123 |   456
  1 |   124 |   457
  2 |   234 |   567