题解 | #获取员工其当前的薪水比其manager当前薪水还高的相关信息#
获取员工其当前的薪水比其manager当前薪水还高的相关信息
http://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
一个用相关子查询的例子 SELECT de.emp_no, dm.emp_no, s.salary, (select s.salary from salaries s left join dept_manager dm on dm.emp_no=s.emp_no where dm.dept_no=de.dept_no LIMIT 1) as manager_salary
from dept_emp de LEFT join salaries s on s.emp_no=de.emp_no LEFT join dept_manager dm on dm.dept_no=de.dept_no
where s.salary>(select s.salary from salaries s left join dept_manager dm on dm.dept_no=de.dept_no where s.emp_no=dm.emp_no LIMIT 1)