题解 | 查找在职员工自入职以来的薪水涨幅情况
查找在职员工自入职以来的薪水涨幅情况
https://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
select
t1.emp_no,
(t2.sal_now - t1.sal_start) as growth
from
(
#获取入职工资
select
s.emp_no,
s.salary as sal_start
from
salaries s
join employees e on e.hire_date = s.from_date
) AS t1
join (
#获取现在工资
select
s.emp_no,
s.salary as sal_now
from
salaries s
join employees e on e.emp_no = s.emp_no
where
s.to_date = '9999-01-01'
) AS t2 on t1.emp_no = t2.emp_no
ORDER BY
growth