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

Postgresql-JSON-Aggregat

select
  pid,
  json_agg(json_build_object('code',code,'name',name))
from
  ...
group by
  pid