Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含许多行的表
我想将一列的所有行连接到单行
例如
columns ------- a b c d e
我想要以下结果
a,b,c,d,e
create table test (a text); insert into test values ('a'), ('b'), ('c'), ('d'), ('e'); select string_agg(a, ',') from test
SQL 提琴示例
SELECT array_to_string(array_agg("column"),',') AS yourColumn FROM Table1
检查看你回答 演示