
with t1 as
(select device_id,date_format(event_date,'%Y-%m') ym
from question_practice_detail
group by device_id,ym
having count(question_id)>1)
t2 as
(select device_id,ym,
lag(ym,1)over(partition by device_id order by ym) ym2
from t1
where period_diff(ym, ym2) = 1
select distinct device_id
from t2
不知道哪里错了