(select
    exam_id as tid,
    count(distinct uid) as uv,
    count(*) as pv
from exam_record
group by exam_id)
union
(select
    question_id as tid,
    count(distinct uid) as uv,
    count(question_id) as pv
from practice_record
group by question_id)
order by left(tid,1) desc, uv desc, pv desc