select user_id,
max(cnt) as max_consec_days
from(
select user_id,
count(*) over(partition by user_id, ndate) as cnt
from(
select user_id,
date_sub(fdate, interval dense_rank() over(partition by user_id order by fdate) day) as ndate
from tb_dau 
where fdate between '2023-01-01' and '2023-01-31'
) temp1
) temp2
group by user_id