SELECT
  exam_id tid,
  COUNT(DISTINCT uid) uv,
  COUNT(exam_id) pv
FROM
  exam_record
GROUP BY
  tid
UNION
SELECT
  question_id tid,
  COUNT(DISTINCT uid) uv,
  COUNT(question_id) pv
FROM
  practice_record
GROUP BY
  tid
ORDER BY
  LEFT(tid, 1) DESC,
  uv DESC,
  pv DESC;