题解 | #查找在职员工自入职以来的薪水涨幅情况#
查找在职员工自入职以来的薪水涨幅情况
https://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
select b.emp_no,(max(b.salary)-min(a.salary))growth
from
(select salaries.emp_no,salaries.salary
from employees join salaries on employees.emp_no=salaries.emp_no and hire_date=from_date)a
join
(select salaries.emp_no,salaries.salary
from salaries where to_date='9999-01-01')b
on a.emp_no=b.emp_no
group by b.emp_no
order by growth
from
(select salaries.emp_no,salaries.salary
from employees join salaries on employees.emp_no=salaries.emp_no and hire_date=from_date)a
join
(select salaries.emp_no,salaries.salary
from salaries where to_date='9999-01-01')b
on a.emp_no=b.emp_no
group by b.emp_no
order by growth