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

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

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

with t2 as(
select 
    s1.emp_no,
    case when s1.to_date = '9999-01-01' then s1.salary else null end as new1,
    start_salary
from salaries s1
join (
select 
    s.emp_no,
    s.salary as start_salary,
    s1.salary as new_salary,
    s.from_date,
    s1.to_date,
    rank() over(partition by emp_no order by from_date) as ranking
from salaries s
left join salaries s1 on s.to_date = s1. from_date and s.emp_no = s1.emp_no   
) t1 on s1.emp_no = t1.emp_no and ranking = 1
)
select 
    emp_no,
    new1 - start_salary as growth
from t2
where new1 is not null 
order by growth

全部评论

相关推荐

05-16 11:16
已编辑
东华理工大学 Java
牛客737698141号:盲猜几十人小公司,庙小妖风大,咋不叫她去4️⃣呢😁
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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