Postgres - aggregate two columns into one item

前端 未结 5 459
忘掉有多难
忘掉有多难 2020-12-25 10:37

I would like to aggregate two columns into one \"array\" when grouping.

Assume a table like so:

friends_map:
=================================
user_i         


        
5条回答
  •  情深已故
    2020-12-25 11:37

    You can use: array[]

    Just do that:

    SELECT user_id, array[friend_id, confirmed]
    FROM friend_map
    WHERE user_id = 1
    GROUP BY 1;
    

提交回复
热议问题