题解 | #查找在职员工自入职以来的薪水涨幅情况#
查找在职员工自入职以来的薪水涨幅情况
http://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
使用employees 关联 salary 把关联条件就取员工号emp_no 和在职的to_date=9999-01-01 作为T1 使用employees 关联 salary 把关联条件就取员工号emp_no和开始日期和入职时间作为关联条件 from_date=hire_date 作T2 然后用T1.salary-T2.salary as growth 参考代码: select t1.emp_no,(t1.a_salary-t2.a_salary) as growth from
(select a.emp_no,b.salary as a_salary from employees as a left join salaries as b on a.emp_no=b.emp_no where b.to_date='9999-01-01') as t1 join (select a.emp_no,b.salary as a_salary from employees as a left join salaries as b on a.emp_no=b.emp_no and b.from_date=a.hire_date) as t2 on t1.emp_no=t2.emp_no order by growth asc;