题解 | #月总刷题数和日均刷题数#
每个题目和每份试卷被作答的人数和次数
http://www.nowcoder.com/practice/203d0aed8928429a8978185d9a03babc
select a.* from
(select DISTINCT exam_id as tid,COUNT(DISTINCT uid) as uv,COUNT(1)
as pv from exam_record GROUP by exam_id
order by uv desc,pv desc)a
union ALL
select b.* from
(select DISTINCT question_id as tid,COUNT(DISTINCT uid) as uv,COUNT(1)
as pv from practice_record GROUP by question_id
order by uv desc,pv desc)b
(select DISTINCT exam_id as tid,COUNT(DISTINCT uid) as uv,COUNT(1)
as pv from exam_record GROUP by exam_id
order by uv desc,pv desc)a
union ALL
select b.* from
(select DISTINCT question_id as tid,COUNT(DISTINCT uid) as uv,COUNT(1)
as pv from practice_record GROUP by question_id
order by uv desc,pv desc)b