with a as (select user_id
,rn
,count(*) sl
from (select fdate
,user_id
,fdate-row_number()over(partition by user_id order by fdate) as rn
from tb_dau
where fdate between '2023-01-01' and '2023-01-31') t
group by user_id,rn)
select user_id,max(sl) as max_consec_days
from a
group by user_id