题解 | #每个题目和每份试卷被作答的人数和次数#
每个题目和每份试卷被作答的人数和次数
https://www.nowcoder.com/practice/203d0aed8928429a8978185d9a03babc
with table1 as (
select exam_id as tid, uid , 'exam' as tag # 构造一个 标签 方便后面按照 试卷题目分别排序
from exam_record
union all
select question_id as tid, uid , 'prac' as tag
from practice_record
)
select tid , count(distinct uid) as uv, count(uid) as pv
from table1
group by tid , tag
order by tag asc , uv desc , pv desc


