select
b.bid, b.oid, b.bed_name, b.meta, b.create_time, b.update_time,
string_agg(g.group_name,',') AS groupNames
from bed as b
LEFT JOIN bed_group bg ON bg.bid = b.bid
LEFT JOIN bgroup g ON g.gid = bg.gid
GROUP BY b.bid
PostgreSQL:根据分组来将多行合并成一行
猜你喜欢
转载自blog.csdn.net/aspire_cj/article/details/103968150
今日推荐
周排行