当前位置:Gxlcms > mysql > 列转行

列转行

时间:2021-07-01 10:21:17 帮助过:44人阅读

test: c1 c2 1 a 1 b 2 c select to_char(wmsys.wm_concat(c2)) , to_char(replace(wmsys.wm_concat(c2),,,/)) from test group by c1 show case: 1 a,b a/b 2 c c 同样的功能函数: select listagg(c2,,) within group(order by c1) from test ;

test:

c1 c2

1 a

1 b

2 c

select
to_char(wmsys.wm_concat(c2)) ,
to_char(replace(wmsys.wm_concat(c2),',','/'))

from
test

group by
c1

show case:

1 a,b a/b

2 c c

同样的功能函数:

select listagg(c2,',') within group(order by c1) from test ;

人气教程排行