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

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

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

  1. 只使用salaries表
select distinct x.emp_no
,(select x1.salary from salaries x1 where x1.emp_no=x.emp_no and to_date='9999-01-01')
-(select x3.salary from salaries x3 where x3.emp_no=x.emp_no and 
  to_date=(select min(to_date) from salaries x2 where x2.emp_no=x.emp_no))
as growth 
from salaries x
where emp_no in (select distinct emp_no from salaries where to_date='9999-01-01')
order by growth
  1. 使用两个表,用from_date=hire_date判断入职salary
select distinct x.emp_no
,(select x1.salary from salaries x1 where x1.emp_no=x.emp_no and to_date='9999-01-01')-
(select x3.salary from salaries x3 where x3.emp_no=x.emp_no
 and x3.from_date=(select hire_date from employees e where e.emp_no=x.emp_no))
as growth
from salaries x
where emp_no in (select distinct emp_no from salaries where to_date='9999-01-01')
order by growth
全部评论

相关推荐

我看到好多人都在说0offer好焦虑,结果一看是投了百度快手字节啥的。好像大家都是只想通过校招进大厂,对小公司是不考虑的吗😂可是能进大厂的难道不是只有少部分人吗,真心发问
梦想是成为七海千秋:沉默的大多数吧,喜欢晒的都是能引起共鸣的大厂,找小厂的人,别人也不认识你这个小厂,就自己偷偷找了实际上大多数人哪有什么机会能找到大厂
点赞 评论 收藏
分享
强大的马里奥:不太可能,我校计算机硕士就业率99%
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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