题解 | #每个题目和每份试卷被作答的人数和次数#
每个题目和每份试卷被作答的人数和次数
https://www.nowcoder.com/practice/203d0aed8928429a8978185d9a03babc
还有一种方法就是要不你就每个表加一个标记字段,比如A表增加一列rk 全为2,B表增加一列rk全为1,然后子查询再按rk字段,uv字段,pv字段再排
( select a.exam_id as tid, count(distinct a.uid) as uv, count(1) as pv from exam_record a group by a.exam_id order by uv desc, pv desc limit 99999 ) union ( select a.question_id as tid, count(distinct a.uid) as uv, count(1) as pv from practice_record a group by a.question_id order by uv desc, pv desc limit 9999 )