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

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

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

select t2.e2 as emp_no,(t2.salary2-t1.salary1) as growth
from 
(select emp_no as e1,salary as salary1,rank()over(partition by emp_no order by from_date) as r from salaries) t1 join
(select emp_no as e2,salary as salary2 from salaries where to_date='9999-01-01') as t2 on t1.e1=t2.e2 
where t1.r=1
order by growth

想确定薪水涨幅,就需要找到入职时间的薪资、最新时间的薪资,以最新的薪资-入职时间的薪资,入职时间通过rank函数获得,最新时间由于要求在职,因此可以确认为‘9999-01-01’

全部评论

相关推荐

07-18 13:49
门头沟学院 Java
26小林不会梦到感谢...:这个点还在面暑期嘛不是马上开秋招了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-29 14:02
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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