我如何在postgres中获得这样的输出
email order_ids
xy@cvf.com 1,3,6,7
yz@vgg.com 2,33,10
模式
订单表
id email
答案 0 :(得分:1)
尝试这样
select email,json_Agg(order_ids) from table1 group by email
OR
select email,string_agg(cast(id as text),',') from table1 group by email