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

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

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

select

emp_no,

(now_salary - ago_salary) as growth

from

(select

emp_no,

sum(case when to_date = '9999-01-01' then salary else 0 end) as now_salary,

sum(case when from_date = hire_date then salary else 0 end) as ago_salary

from salaries natural join employees where emp_no in (

    select emp_no from salaries where to_date = '9999-01-01'

)

group by emp_no

) as tmp

order by growth

1.首先求在职员工当前的薪资,和入职时候的薪资

select

emp_no,

sum(case when to_date = '9999-01-01' then salary else 0 end) as now_salary, -- 当前薪资

sum(case when from_date = hire_date then salary else 0 end) as ago_salary -- 入职时薪资

from salaries natural join employees where emp_no in (

    select emp_no from salaries where to_date = '9999-01-01'

) -- 在职人员

group by emp_no -- 根据编号分组

2.然后在求出涨薪幅度,按照薪资涨幅升序

#担心入职之后被发现很菜怎么办#
全部评论

相关推荐

12-09 00:19
清华大学 Java
Yilena:项目写的太差了,而且这两个项目也很杂,agent方面我不太了解,但对于后端来说这两个项目竞争力感觉不如烂大街项目。 我觉得首要之急是解决你到底是想搞toc/tob还是agent
不给转正的实习,你还去吗
点赞 评论 收藏
分享
影04714:把图书管理系统那个项目经验内容适当的减少掉,然后改成据为己有不要说团队项目,因为图书管理系统这类常见的谁来了都能独立写出来,提问能圆过来即可
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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