SQL之19深入group by

wmlm發表於2007-04-10
Concatenated Groupings Example[@more@]

SQL> select department_id,job_id,manager_id,sum(salary)
2 from employees
3 group by department_id,rollup(job_id),cube(manager_id);

DEPARTMENT_ID JOB_ID MANAGER_ID SUM(SALARY)
------------- ---------- ---------- -----------
SA_REP 149 7000
10 AD_ASST 101 4400
20 MK_MAN 100 13000
20 MK_REP 201 6000
50 ST_MAN 100 5800
50 ST_CLERK 124 11700
60 IT_PROG 102 9000
60 IT_PROG 103 48000
80 SA_MAN 100 10500
80 SA_REP 149 19600
90 AD_PRES 24000
90 AD_VP 100 34000
110 AC_MGR 101 12000
110 AC_ACCOUNT 205 8300
149 7000
10 101 4400
20 100 13000
20 201 6000
50 100 5800
50 124 11700
60 102 9000
60 103 48000
80 100 10500
80 149 19600
90 24000
90 100 34000
110 101 12000
110 205 8300
SA_REP 7000
7000
10 AD_ASST 4400
10 4400
20 MK_MAN 13000
20 MK_REP 6000
20 19000
50 ST_MAN 5800
50 ST_CLERK 11700
50 17500
60 IT_PROG 57000
60 57000
80 SA_MAN 10500
80 SA_REP 19600
80 30100
90 AD_VP 34000
90 AD_PRES 24000
90 58000
110 AC_MGR 12000
110 AC_ACCOUNT 8300
110 20300

49 rows selected.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/271063/viewspace-909737/,如需轉載,請註明出處,否則將追究法律責任。

相關文章