思路:做两个表,一个用来存员工信息及薪水,另一个用来存manager信息及薪水,然后通过where筛选出薪水大于manager的员工,查询出对应信息
select sde.emp_no as emp_no, sdm.emp_no as manager_no, sde.salary as emp_salary, sdm.salary as manager_salary
from
(select s.salary, s.emp_no, de.dept_no
from dept_emp de join salaries s
on de.emp_no = s.emp_no
and s.to_date = '9999-01-01'
) as sde,
(select s.salary, s.emp_no, dm.dept_no
from dept_manager dm join salaries s
on dm.emp_no = s.emp_no
and s.to_date = '9999-01-01'
) as sdm
where sde.dept_no = sdm.dept_no and sde.salary > sdm.salary