题解 | #获取员工其当前的薪水比其manager当前薪水还高的相关信息#
获取员工其当前的薪水比其manager当前薪水还高的相关信息
http://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
先把dept_manager
表变成dept_manager_salary
表 然后join就行了
select de.emp_no, dms.emp_no as manager_no, s.salary as emp_salary, dms.salary as manager_salary from dept_emp de inner join salaries s on de.emp_no = s.emp_no inner join (select dm.*, s.salary from dept_manager dm inner join salaries s on dm.emp_no = s.emp_no) dms on dms.dept_no = de.dept_no where s.salary>dms.salary;