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 MIN(Start_Date) AS project_start,
MAX(End_Date) AS project_end
FROM (
SELECT *,
DATE_SUB(Start_Date, INTERVAL ROW_NUMBER() OVER (ORDER BY Start_Date) DAY) AS grp
FROM Projects
) t
GROUP BY grp
ORDER BY DATEDIFF(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 →
SELECT MIN(Start_Date) AS project_start, MAX(End_Date) AS project_end FROM ( SELECT *, DATE_SUB(Start_Date, INTERVAL ROW_NUMBER() OVER (ORDER BY Start_Date) DAY) AS grp FROM Projects ) t GROUP BY grp ORDER BY DATEDIFF(MAX(End_Date), MIN(Start_Date)), MIN(Start_Date);