listagg( ) within group ( order by ) 与 wm_concat

listagg( ) within group ( order by ) 与 wm_concat

--oracle 11g 及以后适合 最好
select spbywslid,listagg(xm,',') within group (order by spbywslid) col_name from tpg_jtcyqk group by spbywslid;

 

--oracle 10g 及以前版本用
select spbywslid,wm_concat(xm)xm from tpg_jtcyqk group by spbywslid;

 

select deptno,wm_concat(ename)name,count(*)rs from emp group by deptno

select deptno,listagg(ename,',') within group (order by ename ) aa from emp group by deptno

select deptno,listagg(ename,',') within group (order by ename ) aa,count(*)bb from emp group by deptno

posted on 2018-04-04 14:59  低调后的华丽  阅读(328)  评论(0编辑  收藏  举报

导航