--先查出当前职工的工资,条件是日期to_date=9999-01-01
--再查出入职时的工资,条件是新水表的from_date=员工表的hire_date 以及 两表员工编号相等
--然后在做总的查询,将两个表连接起来取别名s1和s2,在查询语句中可以直接做s1.salary-s2.salary计算growth,s1和s2连接的条件就是员工编号相等
--最后以growth做排序,默认升序

select s1.emp_no,(s1.salary-s2.salary) as growth from
(select emp_no,salary from salaries where to_date='9999-01-01')s1
join
(select s.emp_no,s.salary from salaries s join employees e on s.from_date=e.hire_date and s.emp_no=e.emp_no)s2
on s1.emp_no = s2.emp_no
order by growth;