题解 | #查找在职员工自入职以来的薪水涨幅情况#

查找在职员工自入职以来的薪水涨幅情况

http://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5

整体思路就是,找到现在的薪水,入职的薪水,然后做个两笔连接找到想要的目标值

select a.emp_no, (a.salary - b.salary) as growth from (
--现在薪水
select em.emp_no, sa.salary from employees em join salaries sa on em.emp_no = sa.emp_no where sa.to_date = '9999-01-01') a
join(
--入职薪水
select em1.emp_no,sa1.salary from employees em1 join salaries sa1 on em1.emp_no = sa1.emp_no where em1.hire_date = sa1.from_date)b
on a.emp_no = b.emp_no order by growth
全部评论

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务