获取员工其当前的薪水比其manager
获取员工其当前的薪水比其manager当前薪水还高的相关信息
https://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
获取员工其当前的薪水比其manager当前薪水还高的相关信息
https://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
SELECT de.dept_no,de.emp_no,s.salary FROM dept_emp de JOIN salaries s ON de.emp_no=s.emp_no #employee salary
SELECT dm.dept_no,dm.emp_no,s2.salary FROM dept_manager dm JOIN salaries s2 ON s2.emp_no=dm.emp_no #manager salary
SELECT a.emp_no,b.emp_no as manager_no,a.salary AS emp_salary,b.salary AS manager_salary FROM(SELECT de.dept_no,de.emp_no,s.salary FROM dept_emp de JOIN salaries s ON de.emp_no=s.emp_no) as a JOIN(SELECT dm.dept_no,dm.emp_no,s2.salary FROM dept_manager dm JOIN salaries s2 ON s2.emp_no=dm.emp_no) AS b ON a.dept_no=b.dept_no WHERE a.salary>b.salary;
# 连接条件 dept_no 相同 WHERE 员工工资>manager工资
相关推荐