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

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

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

本题中使用两种方法:

1.使用where子句过滤条件 :先筛选再分组
2.使用分组group by :分组的结果在进行筛选

1.使用where子句过滤条件

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

2.使用分组group by

select b.tag,b.difficulty,
round((sum(c.score)-min(c.score)-max(c.score))/(count(c.score)-2),1) clip_avg_score
from examination_info as b
inner join exam_record c on c.exam_id=b.exam_id
group by c.exam_id
having b.tag='SQL'and b.difficulty='hard';
全部评论

相关推荐

牛客97567122...:我最近投的几个,都是要不已读不回,要不不回,还有直接拒绝的
点赞 评论 收藏
分享
做个有文化的流氓:幸遇良师,幸遇好的hr
找工作中的小确幸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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