题解 | #获取员工其当前的薪水比其manager当前薪水还高的相关信息#
获取员工其当前的薪水比其manager当前薪水还高的相关信息
http://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
1.查员工工资
2.查经理工资
3.相同部门,员工薪水大于经理薪水
SELECT E.emp_no,M.manager_no,E.emp_salary,M.manager_salary
FROM
(SELECT de.dept_no,de.emp_no, s.salary emp_salary
FROM dept_emp de
INNER JOIN dept_manager dm on de.dept_no=dm.dept_no
INNER JOIN salaries s on de.emp_no=s.emp_no
WHERE de.emp_no!=dm.emp_no AND s.to_date = '9999-01-01') E,
(SELECT dm.dept_no,dm.emp_no manager_no,s.salary manager_salary
FROM dept_manager dm
INNER JOIN salaries s on dm.emp_no=s.emp_no
WHERE s.to_date = '9999-01-01') M
WHERE E.dept_no=M.dept_no and E.emp_salary>M.manager_salary;
题解-SQL 文章被收录于专栏
SQL刷题