题解 | #查找所有员工自入职以来的薪水涨幅情况#
查找所有员工自入职以来的薪水涨幅情况
http://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
select s1.emp_no as emp_no, s_end - s_begin as growth -- 找出初始工资 from ( select s.emp_no,s.salary as s_begin from employees as e inner join salaries as s on e.emp_no = s.emp_no where e.hire_date = s.from_date ) as s1 inner join -- 找到最后一次的工资 ( select emp_no,salary as s_end from salaries where to_date = '9999-01-01' )as s2 on s1.emp_no = s2.emp_no order by growth;