题解 | #查找在职员工自入职以来的薪水涨幅情况#
查找在职员工自入职以来的薪水涨幅情况
https://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
不join初始工资和现在工资这两张表也可以吧。
我这里是分别从两张表提取emp_no和salary,然后以emp_no相等为判断条件,得到同一员工的初始工资和现在工资,再相减。
select a.emp_no,(b.salary-a.salary) as growth from (select salary,s.emp_no as emp_no from employees e,salaries s where e.hire_date=s.from_date) as a ,(select emp_no,salary from salaries where to_date='9999_01_01') as b where a.emp_no=b.emp_no order by growth