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

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

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

逻辑很简单,就是先用聚合加窗口函数算出归一值,然后再取平均值。

select uid, exam_id, cast(avg(standard) as unsigned) as avg_new_score from

(select uid, exam_id, 
if(count(score) over (partition by exam_id) = 1, score, 
   100*(score - min(score) over (partition by exam_id))/ (max(score) over (partition by exam_id) - min(score) over (partition by exam_id))) as standard
from examination_info inner join exam_record using(exam_id)
where difficulty = "hard" and score is not null) as temp

group by uid, exam_id
order by exam_id, avg_new_score desc
全部评论
点赞 回复 分享
发布于 2022-12-08 08:11 四川

相关推荐

07-07 12:47
门头沟学院 Java
码农索隆:竟然还真有卡体检报告的
点赞 评论 收藏
分享
06-25 09:33
厦门大学 Java
程序员饺子:现在日常估计没啥hc了,等到八月多估计就慢慢有了。双九✌🏻不用焦虑的
投递快手等公司7个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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