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

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

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

select
e.emp_no   as emp_no
,m1.emp_no as manager_no
,s1.salary as emp_salary
,s2.salary as manager_salary
from dept_emp e left join salaries s1
on e.emp_no=s1.emp_no #全体员工工资列
left join dept_manager m1
on e.dept_no =m1.dept_no  #经理列
left join salaries s2
on m1.emp_no=s2.emp_no #经理工资列
where e.to_date='9999-01-01'
and s1.salary>s2.salary #当前薪水比其manager薪水还高

因为必须要列出经理工资和经理工号,所以必须加上几列,给员工附上更多的信息,就是其对应的经理工号和工资

全部评论

相关推荐

牛至超人:把哈工大,再加大加粗,看见闪闪发光的哈工大字样,面试官直接流口水
投递字节跳动等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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