题解 | #月均完成试卷数不小于3的用户爱作答的类别#
月均完成试卷数不小于3的用户爱作答的类别
https://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845
with cet_atc_uid as ( select uid from exam_record join examination_info using(exam_id) group by uid,month(submit_time) having count(submit_time)>=3 ) # 使用with子查询得出符合条件的用户uid select tag, count(start_time) as tag_cnt from exam_record left join examination_info using(exam_id) where uid in (select uid from cet_atc_uid) # 根据已有uid筛选 group by tag # 测试代码的时候没有加tag分组,导致报错,后来知道如果select后面跟了非聚合和聚合就要用group by指明非聚合列 order by tag_cnt desc