You are viewing a single comment's thread. Return to all comments →
Used Oracle:
WITH proj_prev_dates AS ( SELECT Task_ID, Start_Date, End_Date, LAG(End_Date) OVER(ORDER BY Start_Date) AS prev_date FROM Projects ), proj_flags AS ( SELECT ppd.*, CASE WHEN prev_date IS NULL THEN 1 WHEN prev_date = Start_Date THEN 0 ELSE 1 END as proj_flag FROM proj_prev_dates ppd ), proj_labelled AS ( SELECT pf.*, SUM(proj_flag) OVER(ORDER BY Start_Date) AS proj_ID FROM proj_flags pf ) SELECT min_date, max_date FROM ( SELECT proj_ID, MIN(Start_Date) AS min_date, MAX(End_Date) AS max_date, MAX(End_Date) - MIN(Start_Date) AS time_taken FROM proj_labelled GROUP BY proj_ID ) ORDER BY time_taken, min_date;
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 →
Used Oracle: