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

汇总各个部门当前员工的title类型的分配数目

http://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8

# 部门经理的工资表
# 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



全部评论

相关推荐

我已成为0offer的糕手:别惯着,胆子都是练出来的,这里认怂了,那以后被裁应届被拖工资还敢抗争?
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务