日期:2014-05-17  浏览次数:20970 次

哪些部门的平均工资比30部门的平均工资要低
哪些部门的平均工资比30部门的平均工资要低select deptno avg(sal) from emp group by deptno where
avg(sal)<(select avg(sal)from emp where deptno=30);

------解决方案--------------------
SQL code
select deptno
from emp group by deptno
having avg(sal)<(select avg(sal) from emp where deptno=30);

------解决方案--------------------
SQL code
select deptno
from emp group by deptno
having nvl(avg(sal),0)<(select nvl(avg(sal),0) from emp where deptno=30);

------解决方案--------------------
select deptno
from emp group by deptno
having nvl(avg(sal),0)<(select nvl(avg(sal),0) from emp where deptno=30);