题解 | #每个题目和每份试卷被作答的人数和次数#
每个题目和每份试卷被作答的人数和次数
https://www.nowcoder.com/practice/203d0aed8928429a8978185d9a03babc
select t1.exam_id as tid , count(distinct t1.uid) as uv , count(t1.uid) as pv from exam_record t1 group by t1.exam_id union all select t2.question_id as tid , count(distinct t2.uid) as uv , count(t2.uid) as pv from practice_record t2 group by t2.question_id order by substr(tid, 1, 1) desc, uv desc, pv desc # 如结果所示,tid也要降序显示(易漏点) /*SQL*/;