题解 | 查找在职员工自入职以来的薪水涨幅情况
SELECT s1.emp_no, (s1.salary - s2.salary)growth FROM (SELECT emp_no, salary -- 当前工资 FROM salaries WHERE to_date = '9999-01-01')s1 JOIN (SELECT s.emp_no, s.salary -- 入职工资 FROM salaries AS s JOIN employees AS e ON e.emp_no = s.emp_no AND e.hire_date = s.from_date)s2 ON s1.emp_no = s2.emp_no ORDER BY growth;