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

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

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

select 
uid,exam_id,
-- case when round(sum(guiyi)/count(case when guiyi<>0 then guiyi else null end),0) is not null 
-- then round(sum(guiyi)/count(case when guiyi<>'0' then guiyi else null end),0)
-- else 0 end as avg_new_score
round(avg(guiyi),0) avg_new_score
from(
	select 
	uid,exam_id,
	case when cnt<>1 then (score-min_score)/(max_score-min_score)*100 
	else score end as guiyi
	-- case when format((score-min_score)/(max_score-min_score)*score,0)<>0 then format((score-min_score)/(max_score-min_score)*score,0) else score end avg_new_score
	from (
		select 
		a.uid,a.exam_id,a.score,
		min(score) over (partition by exam_id) min_score,
		max(score) over (partition by exam_id) max_score,
		count(score) over (partition by exam_id) cnt
		from exam_record a left join examination_info b
		on a.exam_id =b.exam_id 
		where b.difficulty='hard'
		and score is not null
		-- order by exam_id,uid
	) d
	-- order by exam_id,uid
	-- where (score-min_score)/(max_score-min_score)*score<>0
)e
group by uid,exam_id
order by exam_id asc,avg_new_score desc

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
# 长得好看会提高面试通过率吗? #
4018次浏览 46人参与
# 离家近房租贵VS离家远但房租低,怎么选 #
16907次浏览 137人参与
# 巨人网络春招 #
11527次浏览 224人参与
# 春招至今,你的战绩如何? #
15816次浏览 145人参与
# 你的实习产出是真实的还是包装的? #
3098次浏览 53人参与
# 沪漂/北漂你觉得哪个更苦? #
1553次浏览 41人参与
# 米连集团26产品管培生项目 #
7311次浏览 226人参与
# HR最不可信的一句话是__ #
1091次浏览 32人参与
# AI面会问哪些问题? #
946次浏览 23人参与
# 你做过最难的笔试是哪家公司 #
1247次浏览 22人参与
# AI时代,哪个岗位还有“活路” #
2853次浏览 51人参与
# 不考虑薪资和职业,你最想做什么工作呢? #
152905次浏览 889人参与
# 军工所铁饭碗 vs 互联网高薪资,你会选谁 #
8021次浏览 43人参与
# XX请雇我工作 #
51155次浏览 171人参与
# 简历第一个项目做什么 #
32148次浏览 361人参与
# 简历中的项目经历要怎么写? #
311051次浏览 4265人参与
# 投格力的你,拿到offer了吗? #
178339次浏览 891人参与
# 你最满意的offer薪资是哪家公司? #
76981次浏览 375人参与
# 当下环境,你会继续卷互联网,还是看其他行业机会 #
187605次浏览 1123人参与
# AI时代,哪些岗位最容易被淘汰 #
64760次浏览 890人参与
# 如果重来一次你还会读研吗 #
230018次浏览 2011人参与
# 正在春招的你,也参与了去年秋招吗? #
364353次浏览 2642人参与
牛客网
牛客网在线编程
牛客网题解
牛客企业服务