PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

Postgres:aggrega due colonne in un unico elemento

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)"}