我在SQL下面有表:
ID uniquecol version
1 test 4.4.552.14
2 test 4.4.554
3 test 4.4.543.11
需要输出如下:
test, 1,2,3, 4.4.552.14,4.4.554, 4.4.543.11
答案 0 :(得分:0)
SELECT UNIQUECOL, LISTAGG(ID,',') WITHIN GROUP (ORDER BY ID) AS COL2,
LISTAGG(VERSION,',') WITHIN GROUP (ORDER BY ID) AS COL3
FROM t1
GROUP BY UNIQUECOL;
输出 -
UNIQUECOL COL2 COL3
test 1,2,3 4.4.552.14,4.4.554,4.4.543.11