码迷,mamicode.com
首页 > 其他好文 > 详细

11.07 存取“未来”行

时间:2017-09-14 23:29:18      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:select   ext   条件   员工   from   next   sel   red   date   

找到满足这样条件的员工:即他的收入比紧随其后聘用的员工要少。

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;

11.07 存取“未来”行

标签:select   ext   条件   员工   from   next   sel   red   date   

原文地址:http://www.cnblogs.com/liang545621/p/7523393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!