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

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

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

with temp as (
    select t1.uid,
       t1.exam_id,
       t1.score
    from exam_record t1
    left join examination_info t2
        on t1.exam_id = t2.exam_id
    where t2.difficulty = 'hard'
        and t1.score is not null
), temp2 as (
    select exam_id,
         min(score) as min,
         max(score) as max,
         count(score) as count_score
    from temp
    group by exam_id
), temp3 as (
    select t1.uid,
         t1.exam_id,
         if(count_score = 1, t1.score, (t1.score - min)/(max-min)*100) as avg_new_score
    from temp t1
    left join temp2 t2
        on t1.exam_id = t2.exam_id
) select uid,
         exam_id,
         round(sum(avg_new_score)/count(*)) as avg_new_score
from temp3
group by uid, exam_id
order by exam_id, avg_new_score desc

全部评论

相关推荐

09-01 09:00
已编辑
四川旅游学院 运营
牛客55195891...:主要是专业不好,别的没毛病
牛客解忧铺
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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