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

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

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

  1. 首先要明确每个部门的最高薪水是多少
    select de.dept_no,max(s.salary) maxSalary from dept_emp de ,salaries s where de.emp_no = s.emp_no group by de.dept_no 
  2. 根据部门编号和薪水,反向定位出员工
    select demp.dept_no,demp.emp_no,sa.salary from dept_emp demp,salaries sa,
    (select de.dept_no,max(s.salary) maxSalary from dept_emp de ,salaries s where de.emp_no = s.emp_no group by de.dept_no
    ) a 
    where demp.dept_no = a.dept_no 
       and sa.emp_no = demp.emp_no 
       and sa.salary = a.maxSalary
       order by demp.dept_no 
全部评论

相关推荐

点赞 评论 收藏
分享
2024-12-25 09:09
四川师范大学 运营
想和你交朋友的潜伏者要冲国企:先去沃尔玛亲身感受标准化流程体系,一两年后再跳槽国内任何零售行业,可以有更大选择权吧?
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务