The project planning problem is as below:
Input:
projects (task_id, start_date,end_date)
1, 1-1-2023, 2-1-2023
2, 2-1-2023, 3-1-2023
3, 3-1-2023, 4-1-2023
4, 7-1-2023, 8-1-2023
5, 10-1-2023, 11-1-2023
6, 11-1-2023, 12-1-2023
Desired Output:
1-1-2023, 4-1-2023
7-1-2023, 8-1-2023
10-1-2023, 12-1-2023
Basically, the idea is to have date range for project completion as long as the dates are continuous theyll fall in same range else new_range etc..
I tried below sql but unable to get the desired results (missing some condition to get different minimum start_dates even tried with group by end_Date )
select
(SELECT
min(case when p.start_date<p1.start_date then p.start_date END) from dual),
p1.end_date
from projects p
cross join
(Select distinct start_date,end_date from projects where
end_date not in (Select start_date from projects))
p1
order by 1,2;