Oracle的多行函数

--==========多行函数

/*

select 字段

from

where 条件

group by 字段

having 条件

order by 字段

 

*/

--聚合函数

 

-- 处理的数据是多条的

selectcount(*)from emp;

selectavg(sal)from emp;

 

--计算部门的平均工资,显示部门编号和平均工资

select deptno,avg(sal)

from emp

groupby deptno;

 

--计算部门的平均工资,显示部门编号和平均工资,要求平均工资大于2000

select deptno,avg(sal)

from emp

groupby deptno

havingavg(sal)>2000;


Having和where最大区别在于:        where 后面不能有组函数



猜你喜欢

转载自blog.csdn.net/weixin_42261037/article/details/80946779