使用窗口函数求解

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

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



select d.dept_no, d.emp_no, d.salary
from
(select c.dept_no,c.emp_no,c.salary,
row_number() over(partition by c.dept_no order by c.salary desc) as ranking
from
         (select a.dept_no,a.emp_no,b.salary
          from dept_emp as a inner join salaries as b on a.emp_no = b.emp_no) c
    
)d

where d.ranking = 1
order by d.dept_no;


全部评论

相关推荐

球Offer上岸👑:可能是大环境太差了 太卷了 学历也很重要 hc也不是很多 所以很难
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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