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

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

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

select score from exam_record where exam_id in 
(select exam_id from examination_info 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 score 
limit 0 ,1 

思路 算出平均分 找到第一个大于平均分的试卷得分

select min(score) from exam_record where exam_id in 
(select exam_id from examination_info where tag = 'SQL')
and score >= (select avg(score) from exam_record where exam_id in 
(select exam_id from examination_info where tag = 'SQL'))
 

没有好思路,想不到怎么做才能不重复这段代码

 where exam_id in 
(select exam_id from examination_info where tag = 'SQL')

看其它题解,join也得重复两次。

全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务