ORACLE的WMSYS.WM_CONCAT聚合函数

分组聚合函数WMSYS.WM_CONCAT

合并某一字段:

SQL> select WMSYS.WM_CONCAT(ename) from emp;
WMSYS.WM_CONCAT(ENAME)

SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MIL
根据deptno,合并ename:

SQL> select deptno,WMSYS.WM_CONCAT(ename) from emp group by deptno;
DEPTNO WMSYS.WM_CONCAT(ENAME)

    10 CLARK,MILLER,KING
    20 SMITH,FORD,ADAMS,SCOTT,JONES
    30 ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD

WMSYS.WM_CONCAT(目标字段)over(partition BY 分组 order by 排序)
SQL> select deptno,WMSYS.WM_CONCAT(ename) over (partition by deptno) from emp;
DEPTNO WMSYS.WM_CONCAT(ENAME)OVER(PAR

    10 CLARK,KING,MILLER
    10 CLARK,KING,MILLER
    10 CLARK,KING,MILLER
    20 JONES,FORD,ADAMS,SMITH,SCOTT
    20 JONES,FORD,ADAMS,SMITH,SCOTT
    20 JONES,FORD,ADAMS,SMITH,SCOTT
    20 JONES,FORD,ADAMS,SMITH,SCOTT
    20 JONES,FORD,ADAMS,SMITH,SCOTT
    30 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
    30 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
    30 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
    30 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
    30 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
    30 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
14 rows selected
SQL> select distinct deptno,WMSYS.WM_CONCAT(ename) over (partition by deptno) from emp;
DEPTNO WMSYS.WM_CONCAT(ENAME)OVER(PAR

    10 CLARK,KING,MILLER
    30 WARD,TURNER,ALLEN,JAMES,BLAKE,MARTIN
    20 JONES,FORD,ADAMS,SMITH,SCOTT



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值