题解 | #得分不小于平均分的最低分#

得分不小于平均分的最低分

https://www.nowcoder.com/practice/3de23f1204694e74b7deef08922805b2

select score min_score_over_avg
from exam_record er
left join examination_info ei on er.exam_id=ei.exam_id
where tag='SQL' and score>=(select avg(score) from exam_record where exam_id in (select exam_id from examination_info where tag='SQL'))
order by min_score_over_avg
limit 1

#思路:

有两张表(所以肯定要联结,考虑left join on),

且第二张表不仅有sql(考虑子嵌套一个select)

只要大于平均分的最低那个分数,因此score>符合要求的平均分+排序,limit 1

全部评论

相关推荐

06-17 21:57
门头沟学院 Java
白友:噗嗤,我发现有些人事就爱发这些,明明已读不回就行了,就是要恶心人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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