-
基于多列进行分组-SQL语言入门知识
资源介绍
根据多个列进行分组
*
EMP
“每个部门中,
每种工作的
工资总和”
DEPTNO JOB SAL
------ ------- --------
10 MANAGER 2450
10 PRESIDENT 5000
10 CLERK 1300
20 CLERK 800
20 CLERK 1100
20 ANALYST 3000
20 ANALYST 3000
20 MANAGER 2975
30 SALESMAN 1600
30 MANAGER 2850
30 SALESMAN 1250
30 CLERK 950
30 SALESMAN 1500
30 SALESMAN 1250
JOB SUM(SAL)
-------- -------
CLERK 1300
MANAGER 2450
PRESIDENT 5000
ANALYST 6000
CLERK 1900
MANAGER 2975
CLERK 950
MANAGER 2850
SALESMAN 5600
DEPTNO
------
10
10
10
20
20
20
30
30
30
*
Groups Within Groups
Sometimes there is a need to see results for groups within groups. The slide shows a report that displays the total salary being paid to each job title, within each department.
The EMP table is grouped first by department number, and within that grouping, it is grouped by job title. For example, the two clerks in department 20 are grouped together and a single result (total salary) is produced for all salespeople within the group.
Instructor Note
Demo: l5order1.sql, l5order2.sql
Purpose: To illustrate ordering columns that are grouped by DEPTNO first and ordering columns that are grouped by JOB first.
- 上一篇: 分组函数的类型-SQL语言基础
- 下一篇: 非等连接-SQL语言基础