You are viewing a single comment's thread. Return to all comments →
WITH tagged AS ( SELECT Task_ID, Start_Date, End_Date, CASE WHEN Start_Date = LAG(End_Date) OVER (ORDER BY Start_Date) THEN 0 ELSE 1 END AS is_break FROM Projects ), projected AS ( SELECT *, SUM(is_break) OVER (ORDER BY Start_Date) AS project_id FROM tagged ) SELECT MIN(Start_Date) AS project_start, MAX(End_Date) AS project_end FROM projected GROUP BY project_id ORDER BY DATEDIFF(project_end, project_start), project_start;
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 →