SQL之19深入group by
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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SQL之18深入group bySQL
- SQL之17深入group bySQL
- Oracle PL/SQL之GROUP BY CUBEOracleSQL
- 深入理解GCD之dispatch_groupGC
- 深入淺出SQL教程之Group by和Having(轉貼)SQL
- 深入SQL之merge intoSQL
- sql用法——group bySQL
- SQL入門之4 group by 與子查詢SQL
- 深入SQL之 insert allSQL
- SQL Server之深入理解STUFFSQLServer
- SQL中Group By的使用SQL
- SQL 分組排序group bySQL排序
- PostgreSQL DBA(186) - SQL Group BySQL
- sql case when, Exist ,group by ,聚合SQL
- 兩層GROUP BY效率反而比一層GROUP BY效率高——SQL優化之Everything is possibleSQL優化
- three.js之GroupJS
- SQL函式Group_concat用法SQL函式
- mysql sql_mode ONLY_FULL_GROUP_BYMySql
- SQL -去重Group by 和Distinct的效率SQL
- oracle全文索引之SECTION GROUP_6_PATH_SECTION_GROUPOracle索引
- oracle全文索引之SECTION GROUP_5_AUTO_SECTION_GROUPOracle索引
- oracle全文索引之SECTION GROUP_4_XML_SECTION_GROUPOracle索引XML
- oracle全文索引之SECTION GROUP_3_HTML_SECTION_GROUPOracle索引HTML
- oracle全文索引之SECTION GROUP_2_BASIC_SECTION_GROUPOracle索引
- oracle全文索引之SECTION GROUP_1_NULL_SECTION_GROUPOracle索引Null
- MySQL 之 only_full_group_byMySql
- SQL Server Availability Group Failover 測試SQLServerAI
- SQL改寫的方法,select group by sumSQL
- 【學習】SQL基礎-005-group by子句SQL
- SQL 2012 Group By Rollup, GroupingSQL
- sql中的group by 和 having 用法解析SQL
- dedecms /member/myfriend_group.php SQL Injection VulPHPSQL
- java正規表示式之 groupJava
- 【恩墨學院】深入剖析 Group Replication核心的引擎特性
- 【SQL】19 SQL函式SQL函式
- MySQL sql_mode=only_full_group_by 錯誤MySql
- Linux 上配置 SQL Server Always On Availability GroupLinuxSQLServerAI
- sql語句中where一定要放在group by 之前SQL