postgresql 在SQL中将列值转换为CSV

crcmnpdw  于 2023-02-12  发布在  PostgreSQL
关注(0)|答案(1)|浏览(107)

在SQL中将列值转换为CSV:

rt4zxlrg

rt4zxlrg1#

你需要string_agg,所以应该是this-

SELECT 
    sr_number, name,
    string_agg(city, ', ') WITHIN GROUP (ORDER BY city) AS city
FROM 
    table_name
GROUP BY 
    sr_number, name;

相关问题