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

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

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

select
    uid,
    exam_id,
    round(avg(case when counts = 1 then score 
        when new_score > 100 then 100
        else new_score end
        )) as avg_new_score
from(
    select
        *,
        (score - mins)/(maxs - mins)*100 as new_score
    from (
        select
            uid,
            exam_id,
            score,
            max(score) over(partition by exam_id) as maxs,
            min(score) over(partition by exam_id) as mins,
            count(score) over(partition by exam_id) as counts
        from exam_record
        left join examination_info using (exam_id)
        where difficulty = 'hard' and score is not null
    ) as t
) as tt
group by uid,exam_id
order by exam_id,avg_new_score desc

主要就是窗口聚合的应用

全部评论

相关推荐

能干的三文鱼刷了100道题:公司可能有弄嵌入式需要会画pcb的需求,而且pcb能快速直观看出一个人某方面的实力。看看是否有面试资格。问你问题也能ai出来,pcb这东西能作假概率不高
点赞 评论 收藏
分享
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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