题解 | #月均完成试卷数不小于3的用户爱作答的类别#
月均完成试卷数不小于3的用户爱作答的类别
http://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845
with t1 as (
select
uid
from exam_record
where submit_time is not null
group by uid
having(count(submit_time)/count(DISTINCT substr(submit_time,1,7))>=3)
)
select
i.tag
,count(r.exam_id) as tag_cnt
from examination_info i join exam_record r using(exam_id)
where r.uid in (select * from t1)
group by i.tag
order by tag_cnt desc