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 cte as
(
select *,Start_Date - row_number() over(order by End_Date) as rn
from Projects
)
select min(Start_Date), max(End_Date) from cte
group by rn
order by max(End_Date)-min(Start_Date), min(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 cte as ( select *,Start_Date - row_number() over(order by End_Date) as rn from Projects ) select min(Start_Date), max(End_Date) from cte group by rn order by max(End_Date)-min(Start_Date), min(Start_Date)