Orale-分组函数
文章目录 聚合函数: group by:用来分组,比如:group by deptno having:写在group by 的后面,where写在group by的前面 注意 :聚合函数要用HAVING来过滤 聚合函数: --min:最小值 --max:最大值 --字符类型 select max ( ename ) from emp ; --数值类型: select min ( sal ) from emp ; --日期类型 select min ( hiredate ) from emp ; --sum:求和 --avg:求平均值 select sum ( sal ) 和 , avg ( sal ) 平均值 from emp ; --count:返回总记录数 select count ( * ) from emp ; select count ( comm ) from emp ; --过滤空值: --只有count(*)不过滤空值 group by:用来分组,比如:group by deptno --可以把表中的数据分成指定小组 --查询每个部门的编号,平均工资 select deptno , avg ( sal ) , ename from emp group by deptno , ename ; --注意:在select子句后面除了聚合函数,其他的列都要出现在group