知识点
- 创建出两个表员工表和经理表
- 按照部门进行内连接,筛选条件为员工工资>经理工资的
代码
select b1.emp_no, manager_no, emp_salary, manager_salary
from(
select dept_no, de.emp_no, salary as emp_salary
from dept_emp as de
join salaries as s
on de.emp_no = s.emp_no
)as b1
join (
select dept_no, dm.emp_no as manager_no, salary as manager_salary
from dept_manager as dm
join salaries as s
on dm.emp_no = s.emp_no
)as b2
on b1.dept_no = b2.dept_no
where b1.emp_salary > b2.manager_salary