with t as( select a.*,tag,avg(score) over(partition by a.exam_id) as avg_score from exam_record a left join examination_info b on a.exam_id = b.exam_id where score is not null ) select min(score) min_score_over_avg from t where score >= avg_score and tag='SQL'

京公网安备 11010502036488号