题解 | #对试卷得分做min-max归一化#

对试卷得分做min-max归一化

https://www.nowcoder.com/practice/2b7acdc7d1b9435bac377c1dcb3085d6

select 
min_max.uid,
min_max.exam_id,
round(avg(min_max.score),0) as avg_new_score
from
(
select 
er.uid,er.exam_id,
if(count(1) over(partition by er.exam_id)<>1, #若一个试卷只有一个分数,则直接输出该分数
((er.score-min(er.score) over(partition by er.exam_id))/
(max(er.score) over(partition by er.exam_id)-
min(er.score) over(partition by er.exam_id))) *100,er.score) as score
from examination_info ei 
left join exam_record er
on ei.exam_id=er.exam_id
where ei.difficulty='hard' and er.score is not null
) as min_max
group by min_max.exam_id,min_max.uid
order by min_max.exam_id,avg_new_score desc

全部评论

相关推荐

头像
11-21 11:39
四川大学 Java
是红鸢啊:忘了还没结束,还有字节的5k 违约金
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务