When ran the following query, I got the enames with unordered result . Does anyone know how to get the wm_concat column to order\sort ? I use oracle v10 . Any thoughts are appreciated.Thanks.
select distinct deptno ,wm_concat(ename) over ( partition by deptno order by deptno ) as enames
from emp
group by deptno,ename
order by deptno
current output:
DEPTNO ENAMES
10 MILLER,CLARK,KING
20 SCOTT,JONES,FORD,ADAMS,SMITH
30 MARTIN,JAMES,WARD,ALLEN,TURNER,BLAKE
Target output:
DEPTNO ENAMES
10 CLARK,KING,MILLER
20 ADAMS,FORD,JONES,SCOTT,SMITH
30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
Wanwan