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

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

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

大意了,我没有闪,错了两次

select
    d.uid,d.exam_id,format(sum(calcScore)/count(1),0) as avg_new_score
from 
(
    select
        c.uid,c.exam_id,if(c.maxScore=c.minScore,c.score,((c.score - c.minScore)/(c.maxScore - c.minScore)) * 100) as calcScore
    from 
    (
        select
            a.uid,a.exam_id,a.score,
            min(a.score) over(partition by a.exam_id rows between unbounded preceding and unbounded following) as minScore,
            max(a.score) over(partition by a.exam_id rows between unbounded preceding and unbounded following) as maxScore
        from exam_record a join examination_info b on a.exam_id = b.exam_id and b.difficulty="hard" and a.score is not null
    ) c 
) d group by d.uid,d.exam_id 

order by d.exam_id ,avg_new_score*1 desc

全部评论

相关推荐

想按时下班的我在等o...:我投测试也是这个情况,不知道咋办了
点赞 评论 收藏
分享
哥_留个offer先:跟他说,你这个最好用c#,微软就用c#Java不适合这个项目
点赞 评论 收藏
分享
06-26 10:08
门头沟学院 C++
北京Golang实习,一个月4700,吃住都不报,公司位置在海淀。请问友友怎么看呢?如果要租房的话有什么建议吗
码农索隆:租房肯定是合租了,剩下的钱,差不多够正常吃饭了,看看能不能学到东西吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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