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

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

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

select
    a1.emp_no,
    a1.max_salary - a2.min_salary growth
from (
    select
        emp_no,
        salary max_salary,
        from_date max_from_date
    from salaries
    where to_date = '9999-01-01'
) a1
inner join (
    select 
        t1.emp_no,
        t2.salary min_salary,
        t2.from_date min_from_date
    from employees t1
    inner join salaries t2
    on t1.emp_no = t2.emp_no and t1.hire_date = t2.from_date
) a2
on a1.emp_no = a2.emp_no
order by a1.max_salary - a2.min_salary;

全部评论

相关推荐

04-10 11:56
如皋中学 Java
高斯林的信徒:双c9能简历挂的?
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务