wm_concat函数:字段合并函数
目标:根据某字段相同值,实现其它某字段合并
【实验】
使用实验scott用户下的emp表
SQL> select * from emp;
--先来查看一下emp表的全部内容
EMPNO JOB MGR HIREDATE SAL COMM DEPTNO ENAME
----- --------- ----- ----------- --------- --------- ------ ------
7369 CLERK 7902 1980/12/17 800.00 20
7499 DBA 7698 1981/2/20 1600.00 300.00 30
7521 DBA 7698 1981/2/22 1250.00 500.00 30
7566 MANAGER 7839 1981/4/2 2975.00 20
7654 DBA 7698 1981/9/28 1250.00 1400.00 30
7698 DBA 7839 1981/5/1 2850.00 30
7782 MANAGER 7839 1981/6/9 2450.00 10
7788 ANALYST 7566 1987/4/19 3000.00 20
7839 PRESIDENT 1981/11/17 5000.00 10
7844 DBA 7698 1981/9/8 1500.00 0.00 30
7876 CLERK 7788 1987/5/23 1100.00 20
7900 DBA 7698 1981/12/3 950.00 30
7902 ANALYST 7566 1981/12/3 3000.00 20
7934 CLERK 7782 1982/1/23 1300.00 10
14 rows selected
SQL> select DEPTNO,wm_concat(job) jobs from emp group by deptno;
--查看同一个部门里,存在的全部职位的名称
DEPTNO JOBS
------ -----------------------------------------------------------
10 MANAGER,CLERK,PRESIDENT
20 CLERK,ANALYST,CLERK,ANALYST,MANAGER
30 DBA,DBA,DBA,DBA,DBA,DBA