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

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

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

select
    tag,
    difficulty,
    round((sum(score) - min(score) - max(score))/(count(score)-2),1)
from
    (
        select
            examination_info.tag,
            examination_info.difficulty,
            exam_record.score
        from
            examination_info,
            exam_record
        where
            examination_info.exam_id = exam_record.exam_id
    ) as newform
group by
    tag,
    difficulty
having
    tag = 'SQL'
    and difficulty = 'hard'

本题难度在于取平均数,需要先将两个表通过exam_id内连接,之后通过聚合函数将总数sum()去除min()最小值和max()最大值除以计数count()-2

全部评论

相关推荐

不愿透露姓名的神秘牛友
今天 14:11
很喜欢小米的新车,校招薪资每月22k,攒多久能买?
测试糕手手:别看工资,先看现金流存款。有50W存款以上再考虑,车是消耗品,选适合自己的重要。你有钱就当我没说过
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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