获取员工其当前的薪水比其manager当前薪水还高的相关信息
获取员工其当前的薪水比其manager当前薪水还高的相关信息
https://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
with t1 as( select dept_emp.emp_no, dept_manager.emp_no as manager_no, salary as emp_salary from dept_emp left join salaries using(emp_no) left join dept_manager using(dept_no) where dept_emp.emp_no not in (select emp_no from dept_manager) ), t2 as( select t1.*, salary as manager_salary from t1 left join salaries on(manager_no=salaries.emp_no) ) select * from t2 where emp_salary>manager_salary
dept_emp(emp_no)、dept_manager(dept_no)、salaries(emp_no)、salaries(manager_no) 四表连接