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

select
    uid,
    exam_id,
    round(avg(归一化分数), 0) avg_new_score
from
    (
        select
            uid,
            er.exam_id exam_id,
            if (
                最小值 != 最大值,
                (score - 最小值) / (最大值 - 最小值) * 100,
                score
            ) 归一化分数
        from
            test.examination_info ei
            join test.exam_record er on ei.exam_id = er.exam_id
            join (
                select
                    ei.exam_id,
                    min(score) 最小值,
                    max(score) 最大值
                from
                    test.examination_info ei
                    join test.exam_record er on ei.exam_id = er.exam_id
                where
                    score is not null
                    and difficulty = 'hard'
                group by
                    er.exam_id
            ) a on a.exam_id = ei.exam_id
        where
            score is not null
            and difficulty = 'hard'
    ) b
group by
    b.uid,
    b.exam_id
order by
    exam_id asc,
    avg_new_score desc

全部评论

相关推荐

07-03 16:02
门头沟学院 Java
点赞 评论 收藏
分享
06-23 11:43
门头沟学院 Java
allin校招的烤冷...:我靠,今天中午我也是这个hr隔一个星期发消息给我。问的问题还是一模一样的😅
点赞 评论 收藏
分享
05-26 10:24
门头沟学院 Java
qq乃乃好喝到咩噗茶:其实是对的,线上面试容易被人当野怪刷了
找工作时遇到的神仙HR
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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