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

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

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

#方法一 select tag, difficulty, round(avg(score),1) clip_avg_score from(select exam_id, tag, difficulty from examination_info where tag='SQL' and difficulty = 'hard')t1 join (select uid,exam_id,score from exam_record )t2 on t1.exam_id = t2.exam_id where t2.score>(select min(score) from exam_record where exam_id=t1.exam_id) and t2.score <(select max(score) from exam_record where exam_id = t1.exam_id)

#方法二:窗口函数 select tag, difficulty, round(avg(score),1) clip_avg_score FROM(SELECT E1.exam_id, tag, difficulty, score, row_number() over(partition by exam_id order by score) rk1, row_number() over(partition by exam_id order by score desc) rk2 from examination_info E1 join exam_record E2 on E1.exam_id = E2.exam_id where tag = 'SQL' and difficulty = 'hard' and score is not null)t1 where t1.rk1 > 1 and t1.rk2 > 1 group by tag,difficulty

#方法三 select tag, difficulty, round((sum(score) - max(score) - min(score)) / (count(score) - 2), 1) as clip_avg_score from exam_record join examination_info using(exam_id) where tag="SQL" and difficulty="hard" and score is not null

全部评论

相关推荐

07-03 11:02
中山大学 C++
字节刚oc,但距离九月秋招很近了有两段互联网实习,非腾讯字节。不敢赌转正,现在在纠结去还是不去如果实习俩月离职会有什么后果吗
阿城我会做到的:不去后悔一辈子,能否转正取决于ld的态度,只要他不卡,答辩就是走流程,个人觉得可以冲一把
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
Twilight_m...:经典我朋友XXXX起手,这是那种经典的不知道目前行情搁那儿胡编乱造瞎指导的中年人,不用理这种**
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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