多行函数

2017-01-10  本文已影响0人  52Hz的蓝鲸

1、定义于一组数据,并返回结果

avg函数 

sum函数

count函数 

2、having过滤分组

having 和 where 最大的区别是 where条件后不能用主函数,where的效率高

having是先分组后过滤,where是先过滤后分组

3、group by 语句的增强

select deptno,job,sum(sal) from emp group by deptno,job

+select deptno,sum(sal) from emp group by deptno;

+select sum(sal)  from emp

=select deptno,job,sum(sal) from emp group by rollup(deptno,job)

所以:group by rollup(a,b)=group by a,b+group by a+group by null

break on deptno skip 2---设置相同的部门号只显示一次,不同的部门号跳过两行

break on null---取消设置

上一篇下一篇

猜你喜欢

热点阅读