题解 | #月均完成试卷数不小于3的用户爱作答的类别#
月均完成试卷数不小于3的用户爱作答的类别
https://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845
select tag,count(uid) as tag_cnt from exam_record a left join examination_info b on a.exam_id=b.exam_id where uid in ( select distinct uid from exam_record group by uid,date_format(start_time,'%Y%m') having count(submit_time)>=3 ) group by tag order by tag_cnt desc;
先得出当月完成次数>=3的用户uid,然后在连接的两个表中筛选出这些uid的记录,使用tag进行分组,求得相应数据