将postgresql中的多行连接为单行
我有一张包含许多行的桌子 我希望将列的所有行连接到一行 e、 g 我想得到以下结果将postgresql中的多行连接为单行,postgresql,Postgresql,我有一张包含许多行的桌子 我希望将列的所有行连接到一行 e、 g 我想得到以下结果 a,b,c,d,e 检查一下你的答案 检查一下你的答案 请注意,在现代版本(9.0及更高版本,可以使用string_agg())上。请注意,在现代版本(9.0及更高版本,可以使用string_agg())。 a,b,c,d,e SELECT array_to_string(array_agg("column"),',') AS yourColumn FROM Table1 creat
a,b,c,d,e
检查一下你的答案
检查一下你的答案
请注意,在现代版本(9.0及更高版本,可以使用string_agg())上。请注意,在现代版本(9.0及更高版本,可以使用string_agg())。
a,b,c,d,e
SELECT
array_to_string(array_agg("column"),',') AS yourColumn
FROM Table1
create table test (a text);
insert into test
values ('a'), ('b'), ('c'), ('d'), ('e');
select string_agg(a, ',') from test