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

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

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

1.  通过exam_record.exam_id分组 计算每张试卷的最大分数最小分数作为基础表数据,然后通过基础表数据计算每个用户的每张试卷的经过归化公式之后的的得分情况;有两种情况:如果试卷得分的最大值和最小值相等则表示试卷ID只有一个分数,如果不相等,去归化公式的得分;第三步,根据试卷ID,用户ID分组得到每个人的归化平均分数并按照试卷ID升序,平均归化分数降序排序。


# 计算每张高难度试卷 归化之后所得的分数,并按照归化分数升序,得到归化平均分。

   
   select  B.uid,
           B.exam_id,
           round(avg(B.min_max_score)) avg_new_score 
     from (
   select  ER.uid,
           ER.exam_id, 
           if(max_score=min_score,max_score,round((score-min_score)*100/(max_score-min_score),1)) min_max_score 
     from  exam_record ER join examination_info EI on ER.exam_id = EI.exam_id 
     join (
        select exam_id ,
               min(score) min_score,
               max(score) max_score 
          from exam_record ER 
          group by exam_id 
     ) A on ER.exam_id = A.exam_id 
     where EI.difficulty = 'hard' and ER.score is not null 
     ) B 
     group by B.exam_id,B.uid 
     order by B.exam_id , avg_new_score desc ; 

全部评论

相关推荐

牛客21331815...:像我一投就pass,根本不用焦虑泡池子
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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