题解 | =使用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
全部评论

相关推荐

09-29 00:03
门头沟学院 Java
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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