题解 | #查找在职员工自入职以来的薪水涨幅情况#
查找在职员工自入职以来的薪水涨幅情况
https://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
with tiaojian as ( select emp_no from salaries where to_date="9999-01-01" ) select t.emp_no, sum(t.pt-t.salary) as growth from( select t.emp_no, salary, lead(salary,1)over(partition by t.emp_no order by to_date) as pt from tiaojian t left join salaries s on t.emp_no=s.emp_no ) as t group by t.emp_no order by growth