查询本部门最高工资的员工信息:emp:员工信息表 deptno:部门号 sal:员工薪水
不相关其中几条:
select * from emp e where e.deptno=10 and sal =(select max(sal) from emp where deptno=10)
unino
select * from emp e where e.deptno=20 and sal =(select max(sal) from emp where deptno=20)
union
...
转换:相关子查询
select * from emp e where sal =(select max(sal) from emp where deptno=e.deptno)
子查询不能单独运行:先运行外查询有了e表才能运行子查询
标签:转换,sal,查询,emp,相关,deptno,where,select From: https://www.cnblogs.com/xlm926/p/17438953.html