题解 | #统计复旦用户8月练题情况#

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

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

思路:在表的右边加一列,填入平均值,再对新表过滤出大于平均值和SQL的行,取得分最小值就行了

select min(y.score) as min_score_over_avg
from exam_record as y
left join examination_info as ei using(exam_id)
join (
    select avg(score) as aa
    from examination_info
    join exam_record using(exam_id)
    where tag='SQL') as z
where y.score>=z.aa and ei.tag='SQL'


全部评论
你这个可以直接用窗口函数解决,能直接在后面加一列平均值,不需要用到join 子查询
点赞 回复 分享
发布于 2022-03-03 09:49

相关推荐

点赞 评论 收藏
分享
zzzilik:没事的,才刚刚开始,后面会捞的,这个三天没人发起面试自动结束,但是面试官还是能看到简历,四月份主战场会慢慢捞
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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