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

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

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

# 死方法:3表相连(外层from,  内层 join)
select a.emp_no, b.emp_no, a.salary, b.salary
from (-- 员工 工资
    select de.emp_no, salary, de.dept_no
    from dept_emp de
    inner join salaries s on de.emp_no = s.emp_no
    where de.to_date='9999-01-01' and s.to_date='9999-01-01'
) as a, (-- 领导 工资
select dm.emp_no, salary, dm.dept_no
    from dept_manager dm
    inner join salaries s on dm.emp_no = s.emp_no
    where dm.to_date='9999-01-01' and s.to_date='9999-01-01'
) as b
where a.dept_no=b.dept_no and a.emp_no<>b.emp_no and a.salary>b.salary
全部评论

相关推荐

醉蟀:你不干有的是人干
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务