登录 注册
当前位置:主页 > 资源下载 > 基于多列进行分组-SQL语言入门知识

基于多列进行分组-SQL语言入门知识

  • 更新:2024-07-07 11:38:02
  • 大小:5.26MB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Informix - 数据库
  • 格式:PPT

资源介绍

根据多个列进行分组 * 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.