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

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

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

select 
    uid,
    exam_id,
    round(sum(avg_score)/count(exam_id),0) avg_new_score
from(
    select
        uid,
        exam_id,
        if(max_score=min_score,score,(score-min_score)/(max_score-min_score)*100) avg_score
    from (
        select
            uid,
            er.exam_id,
            score,
            max(score) over(partition by exam_id) max_score,
            min(score) over(partition by exam_id) min_score
        from exam_record er 
        inner join examination_info ei on er.exam_id= ei.exam_id
        where difficulty = 'hard'
        and score is not null
    )tmp
)a
group by uid,exam_id
order by exam_id ,avg_new_score desc

全部评论

相关推荐

Aki-Tomoya:窝趣,人家这是先富带动后富,共同富裕了属于是
投递英伟达等公司10个岗位
点赞 评论 收藏
分享
2024-12-07 21:21
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务