Oracle列转行listagg,wm_concat

多行合并一行
listagg(字段, '分隔符') within group(order by 字段)
listagg(chour, ',') within group(order by chour)

wmsys.wm_concat实现同样效果,默认逗号
select nation,wmsys.wm_concat(city)

listagg详细使用
listagg (T .ENAME, ',') WITHIN GROUP (ORDER BY T .ENAME) over(PARTITION BY T .DEPTNO)
加了over(PARTITION BY T .DEPTNO)后行数不会减少

详细参考
https://www.cnblogs.com/myrunning/p/4335904.html

posted @ 2021-01-22 10:45  少昊  阅读(80)  评论(1编辑  收藏  举报