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

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

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-20 21:57
已编辑
门头沟学院 Java
点赞 评论 收藏
分享
07-10 14:08
已编辑
江西农业大学 Java
拒绝无效加班的小学生...:期望3k吗?java这辈子有了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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