клиента были баллы, начало этого периода и конец?
with d as ( select id, date, points, sum(iif(points > 0, 0, 1)) over (partition by id order by date) as g from Data ) select top (1) with ties id, min(date), max(date) from d where points > 0 group by id, g order by datediff(day, min(date), max(date)) desc;
Обсуждают сегодня