with t as (
    select uid, a.exam_id, b.tag, score
    from exam_record as a
    left join examination_info as b
    on a.exam_id = b.exam_id
)

select level, count(uid) as level_cnt
from (
    select c.uid, d.level
    from (
        select uid
        from t
        where tag = 'SQL' and score > 80
    ) as c
    left join user_info as d
    on c.uid = d.uid
) as e
group by level
order by level_cnt desc;