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

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

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

select
  cf.dept_no,
  salaries.emp_no,
  cf.maxx
from
  dept_emp,
  salaries,
  (
    select
      mm.dept_no,
      max(mm.maxSalary) as maxx
    from
      dept_emp,
      salaries,
      (
        select
          dept_emp.dept_no,
          max(salaries.salary) as maxSalary
        from
          dept_emp,
          salaries
        where
          dept_emp.emp_no = salaries.emp_no
        group by
          dept_emp.dept_no
      ) as mm
    where
      dept_emp.emp_no = salaries.emp_no
      and mm.dept_no = dept_emp.dept_no
    group by
      mm.dept_no
  ) as cf
where
  cf.dept_no = dept_emp.dept_no
  and salaries.emp_no = dept_emp.emp_no
  and salaries.salary = cf.maxx
  and dept_emp.dept_no = cf.dept_no
order by
  cf.dept_no asc;

全部评论

相关推荐

已老实求offer😫:有点像徐坤(没有冒犯的意思哈)
点赞 评论 收藏
分享
10-25 00:32
香梨想要offer:感觉考研以后好好学 后面能乱杀,目前这简历有点难
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务