题解 | #获取员工其当前的薪水比其manager当前薪水还高的相关信息#
获取员工其当前的薪水比其manager当前薪水还高的相关信息
http://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef
分别将员工表与经理表和工资表连接,得到的两个表在以部门号相同连接,筛选员工ID和经理ID不一样,以及员工工资大于经理工资即可
select 员工ID,t.emp_no as 经理ID,员工工资,c.salary as 经理工资 from dept_manager as t join salaries as c on t.emp_no=c.emp_no join (select g.emp_no as 员工ID,f.salary as 员工工资,g.dept_no as 员工部门 from dept_emp as g join salaries as f on g.emp_no=f.emp_no)as m on t.dept_no=员工部门 where 员工ID<>t.emp_no and 员工工资> c.salary ;