题解 | #月均完成试卷数不小于3的用户爱作答的类别#
月均完成试卷数不小于3的用户爱作答的类别
https://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845
- 原来group by 之前可以用where语句? ! 我一直以为用了group by 就只能用having。现在纠正过来这个知识点
- 正确理解:当月均完成试卷数”不小于3的用户
count(exam_id) / count(distinct DATE_FORMAT (start_time, "%Y%M")) >= 3
原来上一次刷题竟是上个月月底,隔了10来天没刷又手生了。现在赶上!这个月中旬,争取把这套进阶题库刷完!!加油!
select tag, count(tag) as tag_cnt from exam_record left join examination_info using (exam_id) 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