Q5_m
kuber
plain_text
4 years ago
706 B
5
Indexable
select start_date, min(end_date) from -- choose start dates that are not end dates of other projects, this way we get start dates of each unique projects (select start_date from projects where start_date not in (select end_date from projects)) s, -- same logic, choose end dates that are not start dates of other projects, this way we get end dates of each unique projects (select end_date from projects where end_date not in (select start_date from projects)) e -- choosing min ensures that for each start date we pick the next minimun consecutive end date where start_date < end_date group by start_date order by datediff(min(end_date), start_date) asc, start_date asc;
Editor is loading...