SQL Project Planning

  • + 0 comments

    WITH myprojectscte AS( SELECT task_id, start_date, end_date, (start_date) - ROW_NUMBER() OVER (ORDER BY start_date) as grp_id FROM Projects ) SELECT MIN(start_date) AS start_date, MAX(end_date) AS end_date FROM myprojectscte GROUP BY grp_id ORDER BY (MAX(end_date)- MIN(start_date)) ASC, start_date ASC;