题解 | #得分不小于平均分的最低分#
得分不小于平均分的最低分
http://www.nowcoder.com/practice/3de23f1204694e74b7deef08922805b2
根据题意把符合条件的数据先列出来成为新的表格
with e as(
select er.score
from exam_record er
left join examination_info ei
on er.exam_id=ei.exam_id
where ei.tag='SQL'
and er.score is not null
)
再找出所有大于等于平均数的数据,找出最小的分数
with e as(
select er.score
from exam_record er
left join examination_info ei
on er.exam_id=ei.exam_id
where ei.tag='SQL'
and er.score is not null
)
select
min(score) min_score_over_avg
from e
where score>=(select avg(score) from e)