PostgreSQL
 sql >> Base de données >  >> RDS >> PostgreSQL

Postgres - regroupe deux colonnes en un seul élément

SELECT user_id, array_agg((friend_id, confirmed)) as friends
FROM friend_map
WHERE user_id = 1
GROUP BY user_id

user_id |           array_agg            
--------+--------------------------------
      1 | {"(2,true)","(3,false)","(4,false)"}