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

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

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

方法一: 两表联查 然后再连接新水表

select t1.emp_no, t3.salary - t2.salary as growth
    from employees t1 join salaries t2 
    on t1.emp_no = t2.emp_no and t1.hire_date = t2.from_date
        join salaries t3 
        on t1.emp_no = t3.emp_no and t3.to_date = '9999-01-01'
order by growth;

方法二: 两表联查 条件 必须有一个表 to_date = '9999-01-01' 目的是为了获取到最高工资 以 emp_no 分组后 直接找出 salary 最小值 最高工资减最低工资即为涨幅情况

select t1.emp_no, (t2.salary - min(t1.salary)) growth
    from salaries as t1, salaries as t2
    where t1.emp_no = t2.emp_no and t2.to_date = '9999-01-01'
    group by t1.emp_no
    order by growth;
全部评论

相关推荐

专业嗎喽:个人信息名字太大,合到电话邮箱那一栏就行,有党员写过党,剩下其他全删,站空太大了 把实习经历丰富,放最前面,然后是个人评价,技能之类的,然后是学校信息。项目经历最后面,可以就选一个自己擅长的。 现在是学校不是92就扣分的,没必要放前面。 然后现在看重实习经历>竞赛经历(校园经历)>课程项目经历
点赞 评论 收藏
分享
12-18 19:36
已编辑
门头沟学院 Java
程序员牛肉:可以的,简历没毛病了。 虽然还是偏向同质化,不过学历不错。后续我觉得重心放到刷实习+摆脱同质化问题上
实习简历求拷打
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务