select es.emp_no,
ms.manager_no,
es.emp_salary,
ms.manager_salary
from
(select de.dept_no,de.emp_no emp_no,s.salary emp_salary
from dept_emp de left join salaries s
on de.emp_no = s.emp_no
where de.to_date = '9999-01-01' and s.to_date = '9999-01-01'
) es /员工工资表/
join
(select dm.dept_no,dm.emp_no manager_no,s.salary manager_salary
from dept_manager dm left join salaries s
on dm.emp_no = s.emp_no
where dm.to_date = '9999-01-01' and s.to_date = '9999-01-01'
)ms /经理工资表/
on es.dept_no = ms.dept_no
and ms.manager_salary < es.emp_salary;