Medium 5

 avatar
Manishyadav514
mysql
3 years ago
360 B
3
Indexable
SELECT Start_Date, MIN(End_Date)
FROM
(SELECT Start_Date 
    FROM Projects 
    WHERE Start_Date NOT IN (SELECT End_Date FROM Projects)) sd,
(SELECT End_Date 
    FROM Projects 
    WHERE End_Date NOT IN (SELECT Start_Date FROM Projects)) ed
WHERE Start_Date < End_Date
GROUP BY Start_Date
ORDER BY DATEDIFF(MIN(End_Date), Start_Date), Start_Date;
Editor is loading...