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

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

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

select t2.uid,t2.exam_id ,
round(avg(new_score),0) as avg_new_score from (
select t1.uid,t1.exam_id,
if(max_score=min_score,t1.score,(t1.score-min_score)*100/(max_score-min_score)) as new_score from (
select e1.uid,e1.exam_id,e1.score,
     min(e1.score) over(partition by e1.exam_id ) as min_score,
     max(e1.score) over(partition by e1.exam_id ) as max_score 
     from exam_record as e1 left join 
examination_info as e2 
on e1.exam_id=e2.exam_id 
where e1.submit_time is not  null and 
e1.exam_id in (
select e2.exam_id from examination_info as e2
    where e2.difficulty='hard' )
    ) t1 
    ) t2 group by t2.uid,t2.exam_id 
    order by t2.exam_id asc,avg_new_score DESC


全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务