题解 | #查找在职员工自入职以来的薪水涨幅情况#
查找在职员工自入职以来的薪水涨幅情况
https://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
with temp_table_1 as (
SELECT * FROM salaries
WHERE (emp_no, from_date) IN (
SELECT emp_no, MIN(from_date)
FROM salaries
GROUP BY emp_no
)
),
temp_table_2 as (
select * from salaries where to_date='9999-01-01'
)
select t_2.emp_no,t_2.salary-t_1.salary as growth from temp_table_2
t_2 ,temp_table_1 t_1 where t_2.emp_no =t_1.emp_no order by growth