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

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

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

select uid,t3.exam_id,round(avg((score - min_score)/(max_score - min_score) * 100),0) as avg_new_score
from exam_record t3
join (
    select t1.exam_id,max(score) as max_score,min(score) as min_score
    from examination_info t1
    join exam_record t2 on t1.exam_id = t2.exam_id
    where difficulty = 'hard'
    group by t1.exam_id
    having count(score) > 1
    ) t4
on t3.exam_id = t4.exam_id
where t3.score is not null
group by uid,t3.exam_id
union all
select max(uid),exam_id,max(score) as avg_new_score
from exam_record
group by exam_id
having count(score) = 1
order by exam_id,avg_new_score desc

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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