#筛选用户 with t1 as (select uid,count(uid) from exam_record er where date_format(start_time,'%Y-%m') = date_format(submit_time,'%Y-%m') and date_format(submit_time,'%Y-%m') = '2021-09' #原来当月指的是9月 group by uid having count(uid) >= 3 ), #合并表 t3 as ( select t2.exam_id,tag from examination_info ei join ( select t1.uid,exam_id from t1 join exam_record er on t1.uid = er.uid ) t2 on ei.exam_id = t2.exam_id) #结果 select tag,count(tag) as tag_cnt from t3 group by tag order by count(tag) desc

京公网安备 11010502036488号