with b as (select day(fdate), user_id, day(fdate) - row_number() over (partition by user_id order by fdate) diff
from tb_dau
where fdate between '2023-01-01' and '2023-01-31'),
d as (select user_id, count(user_id) over (partition by user_id,diff) days from b)
select user_id, max(days) max_consec_days
from d
group by user_id;

京公网安备 11010502036488号