题解 | 获取员工其当前的薪水比其manager当前薪水高
获取员工其当前的薪水比其manager当前薪水还高的相关信息
https://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
select de.emp_no, dm.emp_no as manager_no, s1.salary as emp_salary, s2.salary as manager_salary from dept_emp de inner join dept_manager dm on de.dept_no = dm.dept_no inner join salaries s1 on de.emp_no = s1.emp_no #该员工工资 inner join salaries s2 on dm.emp_no = s2.emp_no #该员工的manager的工资 where s1.salary > s2.salary
salaries被join两次,一次查员工工资,一次查该员工经理的工资
速度不是特别快,但没有子查询,通俗好懂~