题解 | #获取员工其当前的薪水比其manager当前薪水还高的相关信息#
获取员工其当前的薪水比其manager当前薪水还高的相关信息
http://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
SELECT
a.empno as emp_no,a.magno as manager_no,b.salary as 'emp_salary',c.salary as 'manager_salary'
FROM
(SELECT
de.emp_no as empno ,dm.emp_no as magno
FROM
dept_emp as de
JOIN
dept_manager as dm
ON
de.dept_no = dm.dept_no AND de.emp_no <> dm.emp_no
)as a
JOIN
salaries as b
ON
a.empno = b.emp_no
JOIN
salaries as c
ON
a.magno = c.emp_no
WHERE
b.salary > c.salary;