with t1 as (select exam_id as tid,count(distinct uid) as uv,count(exam_id) as pv from exam_record
group by exam_id
order by uv desc,pv desc),

t2 as (select question_id as tid,count(distinct uid) as uv,count(question_id) as pv from practice_record
group by question_id
order by uv desc,pv desc)

select tid,uv,pv from t1
union 
select tid,uv,pv from t2