select user_id,
max(consec_days) as max_consec_days

from (
    select user_id,
    date_sub(fdate, interval t1.n day) as g,
    count(fdate) as consec_days
    from (
        select user_id,
        fdate,
        row_number() over (partition by user_id order by fdate) as n
        from tb_dau t 
        where fdate between '2023-01-01' and '2023-01-31') t1
    group by 1,2) t2

group by 1