欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

列转行

程序员文章站 2022-05-03 21:46:15
...

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 ;