select device_id,date_format(event_date,'%Y年%m月') as ym,
count(*) as cnt
from question_practice_detail
where datediff(last_day(event_date),event_date)<=6
group by device_id, ym
order by device_id, ym