题解 | #子查询解法#

查找在职员工自入职以来的薪水涨幅情况

http://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5

select 
    a.emp_no,
    (select salary from salaries s where a.emp_no=s.emp_no and s.to_date=(select max(to_date) from salaries t where s.emp_no=t.emp_no group by t.emp_no))
    -(select salary from salaries s where a.emp_no=s.emp_no and s.from_date=(select min(from_date) from salaries t where s.emp_no=t.emp_no group by t.emp_no)) as growth
from 
    salaries a
where 
    a.to_date = '9999-01-01'
order by 
    growth asc
一步到位,结构比较简单,但是嵌套了两层子查询,可能不是很好理解,但理清楚关系后还是挺简单的

全部评论

相关推荐

求offer的大角牛:简历写的第一乱,没有突出重点,第二项目太多太杂看不出来有啥核心技术,第三自我评价太多了,第四获得的荣誉没啥含金量,可以不写,反正问题不少
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务