题解 | #SQL类别高难度试卷得分的截断平均值#

SQL类别高难度试卷得分的截断平均值

https://www.nowcoder.com/practice/a690f76a718242fd80757115d305be45

# 1.以exam_record为主表,联表,让tag,difficulty,score在一起
# 2.where筛选条件:tag = sql and difficuty = hard
# 3.计算阶段截断平均值:= (sum(score) - max(score) - min(score) ) / count(score) - 2, 取前两位小数点
# 注意点:题目求的是所有用户-->无需根据用户分组,虽然group by 经常和聚合函数一起用,但是对于整个表进行聚合的时候,就不需要用到group by

select tag,difficulty,
round((sum(score) - max(score) - min(score) ) / (count(score) - 2),1) as clip_avg_score
from exam_record
left join examination_info
on exam_record.exam_id = examination_info.exam_id
where examination_info.tag = 'SQL' and examination_info.difficulty = 'hard'

全部评论

相关推荐

07-27 16:41
门头沟学院 Java
程序员小白条:学历和简历问题,你想走开发,现在很难的啦,尤其后端方向很难走,前端、测开,都会好很多,另外要等8月底和9月初去投日常
点赞 评论 收藏
分享
no_work_no...:大专三年最辛苦的应该是手机和电脑了吧
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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