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

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

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

#先求出最大值和最小值创建新表,再对新表中的数据进行计算和筛选。
select
uid
,exam_id
,round(avg(avg_new_score),0)
from
(
    select
    uid
    ,exam_id
    ,case when maxx = minx then score else
    (score-minx)/(maxx-minx)*100 end avg_new_score
    from
    (
        select
        uid
        ,er.exam_id
        ,score
        ,min(score)over(partition by er.exam_id) minx
        ,max(score)over(partition by er.exam_id) maxx
        from exam_record er left join examination_info ei
        on er.exam_id = ei.exam_id 
        where score is not null
        and difficulty = 'hard'  #筛选出高难度题目
    ) table1
) table2
group by exam_id,uid
order by 2,3 desc;

全部评论

相关推荐

03-10 23:05
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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