题解 | =使用rank()分区函数

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

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

with a as (
select d.dept_no, s.emp_no, s.salary
from dept_emp d inner join salaries s
on d.emp_no = s.emp_no
),

b as (
select dept_no, emp_no, salary, rank() over (partition by dept_no order by salary desc) as r
from a
)

select dept_no, emp_no, salary from b 
where r = 1
全部评论

相关推荐

牛客54175811...:今年对双非很难。1、争取一段大厂实习经历,2、狂磕八股,3、再跑个难度提升的项目。
点赞 评论 收藏
分享
09-22 22:22
中山大学 Java
乌鱼子萨奇:羡慕你啊,直接转正了,都不用经历秋招的炼狱,但是你少经历了很多痛苦的事情啊
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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