select c.user_id,max(c.cnt) as max_consec_days from (select b.user_id,count(*) as cnt from (select a.user_id,a.fdate,day(a.fdate)-ranking as cha from (select user_id,fdate, row_number() over(partition by user_id order by fdate) as ranking ...