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

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

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

-- 单词拼错了哈哈,别介意 
with a as(
select
    emp_no,
    min(case when from_date=hire_date then salary end) as regin, -- 每个用户的入职后薪资
    min(case when to_date='9999-01-01' then salary end) as now -- 当前的在职薪资
from
    salaries a left join employees b using(emp_no)
group by emp_no
having min(case when to_date='9999-01-01' then salary end) is not null -- 仅保留在职的
)
select
emp_no,
now-regin as growth
from a
order by growth

全部评论

相关推荐

牛客62533758...:华为不卡双非,而是卡院校hhhh
点赞 评论 收藏
分享
03-26 12:00
已编辑
门头沟学院 Java
offer魅魔_oc...:100-200每天,你还要倒贴100
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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