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

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

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

分别获取员工工资表以及领导工资表,两表联立查询即可

代码如下:

SELECT t1.emp_no emp_no, 
    t2.emp_no manager_no, 
    t1.salary emp_salary, 
    t2.salary manager_salary
-- 员工工资表
from (
    select de.emp_no, de.dept_no, sa.salary
    from dept_emp de, salaries sa
    where de.emp_no = sa.emp_no
    and de.to_date = '9999-01-01'
    and sa.to_date = '9999-01-01'
) t1
-- 领导工资表
inner join(
    select dm.dept_no, dm.emp_no, sa.salary
    from dept_manager dm, salaries sa
    where dm.emp_no = sa.emp_no
    and dm.to_date = '9999-01-01'
    and sa.to_date = '9999-01-01') t2
on t1.dept_no = t2.dept_no
where t1.salary > t2.salary

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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