We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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
Cookie support is required to access HackerRank
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 →
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