Untitled

 avatar
user_1196610317
mysql
2 years ago
385 B
1
Indexable
Never
SELECT Start_date, MIN(End_Date) as final FROM
(SELECT A.Start_Date FROM Projects A LEFT JOIN Projects B ON A.Start_Date = B.End_Date WHERE B.Task_ID is null) AS Starts JOIN
(SELECT A.End_Date FROM Projects A LEFT JOIN Projects B ON A.End_Date = B.Start_Date WHERE B.Task_ID is null) AS Ends
 ON Start_Date < End_Date
GROUP BY Start_date
ORDER BY MIN(End_date) - Start_date,Start_date;