题解 | #获取员工其当前的薪水比其manager当前薪水还高的相关信息#
获取员工其当前的薪水比其manager当前薪水还高的相关信息
http://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
select t.emp_no,t.manager_no,s1.salary,s2.salary as manaher_salary from (select e.emp_no ,m.emp_no manager_no --第一步:获取员工编号和经理编号 from dept_emp e join dept_manager m on e.dept_no = m.dept_no where e.to_date = '9999-01-01' and m.to_date = '9999-01-01' and e.emp_no <> m.emp_no) t join salaries s1 on t.emp_no = s1.emp_no --第二部通过员工no获取员工sal join salaries s2 on t.manager_no = s2.emp_no --第三步通过经理no获取经理sal and s1.to_date = '9999-01-01' and s2.to_date = '9999-01-01' and s1.salary > s2.salary --第四步 对比员工sal和经理sal