Oracle分组查询1——rullup

来源:互联网 发布:网购比价软件 编辑:程序博客网 时间:2024/05/16 12:00

Oracle分组查询1——rullup

eg.按工龄、部门、职务 从大到小 查询工资和


select to_char(b.hiredate) as 上班日期,a.dname as 部门,b.job as 职务,sum(b.sal) sum_sal from dept a, emp b

where a.deptno=b.deptno group by rollup(

 to_char(b.hiredate),a.dname,b.job)



rollup种从右向左逐个汇总。 查询列中需要对应好 从右向左(红色字部分)

原创粉丝点击