--题目:在工资最高的前3名职工所在部门中查询工资最低的职工
select * from emp where (deptno,sal) in(
select deptno,min(sal) from emp where deptno in(
(select distinct deptno
from (select * from emp where job <> 'PRESIDENT' order by sal desc) --按照工资排序,当然你把老板要排除在外的
where rownum <= 3) ) --排序后取前三的部门名称
group by deptno)
select deptno,ename,sal from ( select deptno,ename,sal from emp 3 where rownum<=3 order by sal desc) order by sal limit 1