赞
踩
一、简要介绍
二、实践过程
select a.deptname name, sum(b.sal) total
from dept a, emp b
where a.deptno = b.deptno
group by a.deptname
union all
select null,sum(b.sal)
from dept a, emp b
where a.deptno = b.deptno;
等同于:
select a.deptname, sum(b.sal)
from dept a, emp b
where a.deptno = b.deptno
group by rollup(a.deptname);
select a.deptname name, b.job, sum(b.sal) total
from dept a, emp b
where a.deptno = b.deptno
group by rollup(a.deptname, b.job)
select case grouping(a.deptname) when 1 then '总计' else a.deptname end as dname, case grouping(b.job) when 1 then '分计' else b.job end as job, sum(b.sal) total from dept a, emp b where a.deptno = b.deptno group by rollup(a.deptname, b.job)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。