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

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

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

select t.emp_no,max(t.salary)-min(t2.salary) growth from salaries t left join salaries t2 on t.emp_no = t2.emp_no where t.to_date='9999-01-01' group by t.emp_no order by growth

单表自连接后,where过滤出在职员工,以员工分组 组1 10001 85097 10001 85097 组2 10001 85097 10001 85097

此时在取t表的最大工资和t2表的最小工资之差就是工资的涨幅了

全部评论

相关推荐

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