--关于null的处理 ,null是一个字段没有被赋值时的状态
--注意:任何数据与null进行运算结果一定为null,如果要避免这个问题,可以在运算时给null设置默认值
-- nvl(字段,默认值):如果字段内容不为null则返回当前值,如果为null则用默认值代替
--查询 员工的姓名,工资,奖金 , 月收入(工资+奖金)
select ename,sal,comm,sal+ nvl(comm,0) as 月收入 from emp
--在查询语句查找某字段为null的情况
--查询 comm为null(空)的员工信息
select * from emp where comm is null
--查询 comm 不为null的员工信息
select * from emp where comm is not null
聚合函数
--max(列):返回该列的最大值
--查询20部门中最高工资是多少
select max(sal) from emp where deptno=20
--查询公司最晚入职时间是多少
select max(hiredate) from emp
--min(列):返回该列的最小值
--查询20部门中最低工资是多少
select min(sal) from emp where deptno=20
--查询公司最早入职时间是多少
select min(hiredate) from emp
--sum(数字列):返回该列数字的总和
--计算20部门的工资总支出多少
select sum(sal) from emp where deptno=20
--avg(数字列):返回该数字列的平均工资
--计算出20部门的平均工资是多少
select avg(sal) as 平均工资 from emp