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

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

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

WITH a AS (SELECT uid, exam_id, score
            FROM exam_record JOIN examination_info USING(exam_id)
            WHERE difficulty = 'hard'),
     b AS (SELECT exam_id, COALESCE(MAX(score),0) AS maximum, COALESCE(MIN(score),0) AS minimum
          FROM exam_record
          GROUP BY exam_id)
SELECT uid,exam_id, ROUND(AVG(new_score)) AS avg_new_score
FROM(SELECT *, 
     IF(maximum = minimum, score, ((score-minimum)/(maximum-minimum))*100) AS new_score
     FROM a LEFT JOIN b USING (exam_id)) AS d
WHERE score IS NOT NULL
GROUP BY uid, exam_id
ORDER BY exam_id ASC, avg_new_score DESC;
全部评论

相关推荐

10-07 23:57
已编辑
电子科技大学 Java
八街九陌:博士?客户端?开发?啊?
点赞 评论 收藏
分享
11-14 16:13
已编辑
重庆科技大学 测试工程师
Amazarashi66:不进帖子我都知道🐮❤️网什么含金量
点赞 评论 收藏
分享
1 收藏 评论
分享
牛客网
牛客企业服务