You are viewing a single comment's thread. Return to all comments →
mysql: WITH raw1 as(SELECT Task_ID, Start_Date, End_Date, LAG(End_Date) OVER(ORDER BY End_Date) as E1 FROM projects), raw2 AS(SELECT Task_ID, Start_Date, End_Date, (CASE WHEN E1=Start_Date AND End_Date-E1=1 THEN 1 ELSE 0 END) AS binary1 FROM raw1 GROUP BY 1,2,3), raw3 AS(SELECT task_ID, Start_Date, End_Date, SUM(CASE WHEN binary1 = 0 THEN 1 ELSE 0 END) OVER (ORDER BY Task_ID ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS project_label FROM raw2) SELECT MIN(Start_Date),MAX(End_Date) FROM raw3 GROUP BY project_label ORDER BY COUNT(project_label) ASC, Start_Date ASC
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 →