题解 | #获取员工其当前的薪水比其manager当前薪水还高的相关信息#

获取员工其当前的薪水比其manager当前薪水还高的相关信息

http://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef

SELECT staff.emp_no,manager.emp_no AS manager_no,staff.all_salary AS emp_salary,manager.ma_salary AS manager_salary
FROM (SELECT A.emp_no,A.dept_no,B.salary AS all_salary
FROM dept_emp A JOIN salaries B
ON A.emp_no = B.emp_no) AS staff
LEFT JOIN (SELECT C.emp_no,C.dept_no,D.salary AS ma_salary
FROM dept_manager C INNER JOIN salaries D
ON C.emp_no = D.emp_no) AS manager
ON staff.dept_no = manager.dept_no
WHERE staff.all_salary >manager.ma_salary

全部评论

相关推荐

专心打鱼:互联网搬运工,贴子都要偷
点赞 评论 收藏
分享
1 收藏 评论
分享
牛客网
牛客企业服务