Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将postgresql中的多行连接为单行_Postgresql - Fatal编程技术网

将postgresql中的多行连接为单行

将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

我有一张包含许多行的桌子

我希望将列的所有行连接到一行

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
create table test (a text);

insert into test
values ('a'), ('b'), ('c'), ('d'), ('e');

select string_agg(a, ',') from test