题解 | #月均完成试卷数不小于3的用户爱作答的类别#
月均完成试卷数不小于3的用户爱作答的类别
https://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845
with data_f_use as ( select uid, exam_id, start_time, submit_time, tag from exam_record left join examination_info using (exam_id) ) select tag, count(tag) as tag_cnt from data_f_use where uid in ( select uid from exam_record where submit_time is not null group by uid having (count(exam_id) / count(distinct date_format(start_time, '%Y%m'))) >= 3 ) group by tag order by tag_cnt desc
月均完成试卷数不小于3的用户必须从submit_time is not null 里筛选
用户爱作答类别必须从所有数据里筛选