题解 | #获取所有非manager员工当前的薪水情况#
获取所有非manager员工当前的薪水情况
http://www.nowcoder.com/practice/8fe212a6c71b42de9c15c56ce354bebe
这题还挺简单的.
关键点就是where子句排除经理.
select
-- 员工部门
t1.dept_no ,
t1.emp_no ,
(select t3.salary from salaries t3 where t3.emp_no = t1.emp_no) as salary
from dept_emp t1
where not EXISTS
(
select 1 from dept_manager t2
where t1.emp_no = t2.emp_no
)
-- 员工部门
t1.dept_no ,
t1.emp_no ,
(select t3.salary from salaries t3 where t3.emp_no = t1.emp_no) as salary
from dept_emp t1
where not EXISTS
(
select 1 from dept_manager t2
where t1.emp_no = t2.emp_no
)