题解 | #查找薪水记录超过15条的员工号emp_no以及其对应的记录次数t#

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

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

# 请你将用户作答高难度试卷
# 的得分
# 在每份试卷作答记录内执行min-max归一化后缩放到[0,100]区间,
# 并输出用户ID、试卷ID、归一化后分数平均值;
# 最后按照试卷ID升序、归一化分数降序输出。
select uid,exam_id,
round(if(maxs-mins=0,avgs,if(avgs-mins=0,0,100*(avgs-mins)/(maxs-mins))) )avg_new_score 
-- 第二步 解决一份卷子只有一人作答情况
from 
(
select distinct exam_id,uid,
avg(score) over(partition by exam_id,uid) avgs,
min(score) over(partition by exam_id) mins,
max(score) over(partition by exam_id) maxs
from exam_record
where exam_id in (select exam_id from examination_info where difficulty = 'hard')
and score is not null
)a-- 第一步:来找到最大最小分数和一个人一个卷子做了多次情况
order by exam_id asc, avg_new_score desc

全部评论

相关推荐

caicaidog:现实里没实习的还是占多数的
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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