题解 | #获取每个部门中当前员工薪水最高的相关信息#

获取每个部门中当前员工薪水最高的相关信息

https://www.nowcoder.com/practice/4a052e3e1df5435880d4353eb18a91c6

with A as
    (
        select 
            d.dept_no,
            max(salary) as maxSalary
        from
            dept_emp d
            join salaries s on d.emp_no = s.emp_no
        where
            s.to_date = '9999-01-01'
        group by
            dept_no
        order by
            dept_no
    ) 

select d.dept_no,d.emp_no,maxSalary from A,salaries s,dept_emp d
where A.dept_no=d.dept_no and
      A.maxSalary=s.salary
and s.emp_no=d.emp_no
order by dept_no

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务