题解 | 查找在职员工自入职以来的薪水涨幅情况
查找在职员工自入职以来的薪水涨幅情况
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
查看7道真题和解析