题解 | #SQL25 获取员工其当前的薪水比其manager当前薪水还高的相关信息#
获取员工其当前的薪水比其manager当前薪水还高的相关信息
http://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
select t.emp_no, t.manager_no, t.emp_salary, t.manager_salary from (select dp.dept_no, dp.emp_no, dr.emp_no manager_no, ss.salary emp_salary, ss2.salary manager_salary, dp.to_date from dept_emp dp left join dept_manager dr on dp.dept_no = dr.dept_no left join salaries ss on ss.emp_no = dp.emp_no left join salaries ss2 on ss2.emp_no = dr.emp_no) t # 子查询 where t.emp_no != t.manager_no and t.to_date = '9999-01-01' and emp_salary > manager_salary