You are viewing a single comment's thread. Return to all comments →
with temp as ( select *, row_number() over(order by end_date) as rn from projects ), temp2 as (select a.task_id , a.start_date , a.end_date , b.end_date as next_end_date , datediff(dd, b.end_date, a.end_date) datedif , case when datediff(dd, b.end_date, a.end_date) = 1 then 0 else 1 end flag from temp as a left join temp as b on a.rn = b.rn+1 ), temp3 as (select * , sum(flag) over(order by end_date) as group_id from temp2 ) select min(start_date), max(end_date) from temp3 group by group_id order by datediff(dd, min(start_date), max(end_date)), min(start_date)
Seems like cookies are disabled on this browser, please enable them to open this website
SQL Project Planning
You are viewing a single comment's thread. Return to all comments →