SQL Project Planning

  • + 0 comments

    With Cte1 as (Select Start_Date, row_number() over(order by Start_Date) as rn From Projects where Start_Date not in (Select End_Date From Projects) ), Cte2 as ( Select End_Date, row_number() over(order by End_Date) as rn From Projects where End_Date not in (Select Start_Date From Projects)) Select Cte1.Start_Date,Cte2.End_Date From Cte1 Join Cte2 on Cte2.rn = Cte1.rn order by Datediff(Day,start_Date,End_Date), Start_Date