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

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

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

# 部门经理的工资表
# with m_s,em_s as 
# (select *from dept_manager d
# inner join salaries s
# on d.emp_no = s.emp_no) m_s
# # 员工的薪水(包括经理的)总表
# (select*from dept_emp em
# inner join salaries s 
# on em.emp_no = s.emp_no)em_s
select ems.emp_no as empno
,ms.emp_no as manager_no
,ems.salary as emp_salary
,ms.salary as manager_salary 
from 
(
select d.dept_no,d.emp_no,s.salary
 from dept_manager d
join salaries s
on d.emp_no = s.emp_no
) ms
 join 
(select em.dept_no,em.emp_no,s.salary 
from dept_emp em
join salaries s 
on em.emp_no = s.emp_no
)ems
on ms.dept_no =ems.dept_no
where ems.salary > ms.salary 
and ms.dept_no = ems.dept_no



全部评论

相关推荐

11-09 12:17
清华大学 C++
out11Man:小丑罢了,不用理会
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务