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

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

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

select
	uid,
    exam_id,
	round(avg(ifnull(((score - min_score) / (max_score - min_score)) * 100, score)),0) avg_new_score
	
from exam_record
join examination_info
	using (exam_id)
join (
	select
		exam_id,
		case
			when count(*) = 1 then 0
			when count(*) > 1 then min(score)
			else null
		end as min_score,
		case
			when count(*) = 1 then 0
			when count(*) > 1 then max(score)
			else null
		end as max_score
	from exam_record
	join examination_info
		using (exam_id)
	where difficulty = 'hard' and submit_time is not null
	group by exam_id
) t
using (exam_id)
group by uid, exam_id
having avg_new_score is not null
order by exam_id, avg_new_score desc;

全部评论

相关推荐

点赞 评论 收藏
分享
07-11 11:10
门头沟学院 Java
请问各位大三兄弟们跟hr说多久实习时间到时候可以提前跑路吗?
程序员小白条:问就是六个月以上,可以一年,实习都这样,你入职后想跑就跑
点赞 评论 收藏
分享
06-02 15:53
阳光学院 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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