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

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

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

select后使用子查询即可

select e.emp_no,
(
    (select s2.salary from salaries s2
where s2.emp_no=e.emp_no and s2.to_date='9999-01-01')
    -
    (select s1.salary from employees e1,salaries s1
where e1.emp_no=s1.emp_no and s1.from_date=e1.hire_date and e1.emp_no=e.emp_no)
    )
as growth
from employees e,salaries s
where e.emp_no=s.emp_no and to_date='9999-01-01'
group by e.emp_no
order by growth
全部评论

相关推荐

头像
05-14 12:29
安卓
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务