select 
tid,
uv,
pv
from 
(
    select 
exam_id tid,
count(distinct uid) uv,
count(exam_id) pv
from 
exam_record
group by exam_id
order by uv desc,pv desc
) a
union all
select 
tid,
 uv,
pv
from 
(
    select 
question_id tid,
count(distinct uid) uv,
count(question_id) pv
from 
practice_record
group by question_id
order by uv desc,pv desc
) b