题解 | 获取员工其当前的薪水比其manager当前薪水
获取员工其当前的薪水比其manager当前薪水还高的相关信息
https://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
SELECT t1.emp_no, t2.emp_no as manager_no, t1.salary as emp_salary, t2.salary as manager_salary FROM (select a.emp_no, a.dept_no, b.salary from (select emp_no,dept_no from dept_emp where emp_no not in (select emp_no from dept_manager)) a left join salaries b on a.emp_no = b.emp_no) t1 ---员工工资 LEFT JOIN (select a.dept_no, a.emp_no, b.salary from dept_manager a left join salaries b on a.emp_no = b.emp_no) t2 ----领导工资 ON t1.dept_no = t2.dept_no WHERE t1.salary > t2.salary;