select deptno,(select min(sal) from emp where deptno = e.deptno)
from emp e
where (select min(sal) from emp) > (select min(sal) from emp where deptno =20);
为什么没有查询结果?
改成这个样子就可以了
select deptno, (select min(sal) from emp where deptno = e.deptno)
from emp e
group by deptno
having (select min(sal) from emp where deptno = e.deptno ) > (select min(sal) from emp where deptno =20);
select deptno,(select min(sal) from emp where deptno = e.deptno)from emp e where (select min(sal) from emp) > (select min(sal) from emp where deptno =20);因为你这条语句查询的结果为emp表的最低工资而这个最低工资正好就是20号部门的最低工资800,所以比较不成立就不会有输出结果。
谢谢,我的意思是我代码没有执行结果的原因,但是还是非常感谢!