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

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

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

select t2.emp_no,(t2.salary-t1.salary) as growth
from 
(select a1.emp_no emp_no,a1.salary salary
from salaries a1 join salaries a2
on a1.from_date =a2.to_date and a1.to_date="9999-01-01")t2
left join
(select a.emp_no emp_no,salary
from employees a join salaries b 
on a.hire_date =b.from_date)t1
on t2.emp_no=t1.emp_no
order by growth asc

#法2:
select a.emp_no, (b.salary - c.salary) as growth
from
	employees as a
    inner join salaries as b
    on a.emp_no = b.emp_no and b.to_date = '9999-01-01'
    inner join salaries as c
    on a.emp_no = c.emp_no and a.hire_date = c.from_date 
order by growth asc

全部评论

相关推荐

07-01 23:23
郑州大学 Java
否极泰来来来来:牛客迟早有高三的
点赞 评论 收藏
分享
06-12 16:00
天津大学 Java
牛客30236098...:腾讯坏事做尽,终面挂是最破防的 上次被挂了后我连简历都不刷了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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