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

每类试卷得分前3名

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

select * 
from(
	#第二步:在第一步基础上分试卷类型标行号
	select tag,uid,row_number() over(partition by tag) ranking
	from(#第一步:统计每类试卷各用户的最高分最低分并排序
		select tag,uid,max(score) max_score,min(score) min_score
		from examination_info ei join exam_record er
			on ei.exam_id =er.exam_id 
			and score is not null
		group by tag,uid
		order by tag,max_score desc,min_score desc,uid desc
		) as 第一步的表
	) as 第二步的表
where ranking <=3;

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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