SQL_wm_concat函數實驗:實現欄位合并,sql_wm_concat欄位

來源:互聯網
上載者:User

SQL_wm_concat函數實驗:實現欄位合并,sql_wm_concat欄位

原創作品,出自 “深藍的blog” 部落格,歡迎轉載,轉載時請務必註明以下出處,否則追究著作權法律責任。

深藍的blog:http://blog.csdn.net/huangyanlong/article/details/41347109 

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

原創作品,出自 “深藍的blog” 部落格,歡迎轉載,轉載時請務必註明以下出處,否則追究著作權法律責任。

深藍的blog:http://blog.csdn.net/huangyanlong/article/details/41347109

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.