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.
Select PS.Start_Date, PE.End_Date From
(Select Start_Date, ROW_NUMBER() Over(Order by Start_Date) As Num From Projects Where Start_Date Not in (Select End_Date From Projects)) PS
Join
(Select End_Date, ROW_NUMBER() Over(Order by End_Date) As Num From Projects Where End_Date Not in (Select Start_Date From Projects)) PE
On PS.Num = PE.Num
Order by Convert(Int, CONVERT(datetime,End_Date)) - Convert(Int, CONVERT(datetime,Start_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 →
MS SQL SERVER
Select PS.Start_Date, PE.End_Date From (Select Start_Date, ROW_NUMBER() Over(Order by Start_Date) As Num From Projects Where Start_Date Not in (Select End_Date From Projects)) PS Join (Select End_Date, ROW_NUMBER() Over(Order by End_Date) As Num From Projects Where End_Date Not in (Select Start_Date From Projects)) PE On PS.Num = PE.Num Order by Convert(Int, CONVERT(datetime,End_Date)) - Convert(Int, CONVERT(datetime,Start_Date)), Start_Date;