找到满足这样条件的员工:即他的收入比紧随其后聘用的员工要少。
select ename,sal,hiredate
from (
select a.ename,a.sal,a.hiredate,
(select min(hiredate) from emp b
where b.hiredate>a.hiredate
and b.sal>a.sal) as next_sal_grtr,
(select min(hiredate) from emp b
where b.hiredate>a.hiredate) as next_hire
from emp a
)x
where next_sal_grtr=next_hire;