题解 | #查找在职员工自入职以来的薪水涨幅情况#
查找在职员工自入职以来的薪水涨幅情况
http://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5
考点:多层select/join
- ps:提交四次没过的原因居然是没有order by,气!qwq
select w1.emp_no1 as emp_no, (salary2-salary1) as growth from (select e.emp_no as emp_no1, s.salary as salary1 from employees e left join salaries s
on e.emp_no = s.emp_no
where e.hire_date = s.from_date
group by e.emp_no) as w1 inner join
(select e.emp_no as emp_no2, s.salary as salary2 from salaries s left join employees e
on e.emp_no = s.emp_no
where to_date = '9999-01-01'
group by e.emp_no) as w2 on w1.emp_no1 = w2.emp_no2
order by growth