题解 | #获取员工其当前的薪水比其manager当前薪水

获取员工其当前的薪水比其manager当前薪水还高的相关信息

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

#匹配员工的manager
select 
emp_no,
manager as manager_no,
s1 as emp_salary,
s2 as manager_salary
from
(select
t1.emp_no,
t1.manager,
s.s1,
ss.s2
from
(
select 
d.emp_no,
d.dept_no,
m.emp_no as manager
from dept_emp d
left join dept_manager m on d.dept_no = m.dept_no
)t1
left join (select emp_no,salary as s1 from salaries) s on t1.emp_no = s.emp_no
left join (select emp_no,salary as s2 from salaries) ss on t1.manager = ss.emp_no
)t2
where s1>s2

全部评论

相关推荐

有趣的牛油果开挂了:最近这个阶段收到些杂七杂八的短信是真的烦
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务