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

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

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

with b as (
    select distinct emp_no
    from salaries
    where to_date = '9999-01-01'
),
a as (
    select b.emp_no,salary,rank() over(partition by b.emp_no order by from_date) as rk
    from b left join salaries
    on b.emp_no = salaries.emp_no
),
c as (
    select emp_no,max(rk) as maxrk,min(rk) as minrk
    from a
    group by emp_no
),
d as (
    select c.emp_no,a1.salary - a2.salary as growth
    from c left join a as a1
    on c.emp_no = a1.emp_no and c.maxrk = a1.rk
    left join a as a2
    on c.emp_no = a2.emp_no and c.minrk = a2.rk
)

select *
from d
order by growth

怎么还有工资先涨后降的操作啊

全部评论

相关推荐

流浪的神仙:无恶意,算法一般好像都得9硕才能干算法太卷啦
点赞 评论 收藏
分享
mjasjon:这种trash中厂 简历过筛概率比大厂还低(除阿里系)
投递哔哩哔哩等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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