题解 | #每类试卷得分前3名#

每类试卷得分前3名

https://www.nowcoder.com/practice/255aa1863fe14aa88694c09ebbc1dbca

with tmp as
(
select 
distinct 
tag tid,
uid,
-- score,
max(score) over(partition by tag,uid ) max_score,
min(score) over(partition by tag,uid ) min_score
from 
exam_record a left join
examination_info b
on a.exam_id=b.exam_id
where score is not null
)

select 
*
from 
(
select 
tid,
uid,
row_number() over (partition by tid order by max_score desc,min_score desc,uid desc) ranking
from
tmp
) a
where a.ranking <=3

知识点

使用窗口函数之后取TOPN,要用子查询,固定的写法

select *
       from (select *,row_number() over(partition by 姓名 order by 成绩 desc)as ranking
                    from 各科成绩表) as a
       where ranking <= 2;
全部评论

相关推荐

这不纯纯作弊了吗😢😢😢
编程界菜鸡:信这个的这辈子有了,这智商你靠啥都没用
点赞 评论 收藏
分享
鬼迹人途:你去投一投尚游游戏,服务器一面,第一个图算法,做完了给你一个策略题,你给出方案他就提出低概率问题,答不上当场给你挂
点赞 评论 收藏
分享
小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
07-01 17:14
中北大学 Java
兄弟们是真是假
牛客46374834...:我在boss上投java岗从来没成功过
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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