题解 | 很灵活的一题,通过非独特键相连,不同筛选形成错位
查找在职员工自入职以来的薪水涨幅情况
https://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
select a.emp_no,(a.salary - b.salary) growth from salaries a inner join salaries b on a.emp_no=b.emp_no and (a.emp_no,a.from_date) in (select emp_no,max(from_date) from salaries group by emp_no) and (b.emp_no,b.from_date) in (select emp_no,min(from_date) from salaries group by emp_no) and a.to_date='9999-01-01' order by growth asc