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

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

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

排除“一个”最大最小值,想到row_number窗口函数+子查询;
成功代码如下:(完全感觉做复杂了。。稍等看下大家怎么写的)

with x as(
select tag,difficulty,score,row_number() over(order by score desc ) r
from(
select score,tag,difficulty
from exam_record a
left join examination_info b
on a.exam_id = b.exam_id
where tag = "SQL" 
and difficulty = "hard"
and score is not null
)c
)
select tag,difficulty,round(avg(score),1) as clip_avg_score
from x
where r != (select max(r) from x) 
and r != (select min(r) from x)
group by tag,difficulty

#你觉得今年春招回暖了吗#
全部评论

相关推荐

07-15 14:14
门头沟学院 Java
7.10投递7.15感谢信
投递地平线等公司7个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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