Mistake in a problem solution I am trying to solve this problem from hackerrank
this far I've written this solution

select Start_Date, min(End_Date)
from 
   (select Start_Date from projects where Start_Date not in (select End_Date from projects)),
   (select End_Date from projects where End_Date not in (select Start_Date from projects))
where Start_Date &lt; End_Date 
group by Start_Date
order by datediff(day, min(End_Date), Start_Date) desc


But it shows that this answer is wrong though when I compare I get the results I planned to get. I'd much appreciate a little help to find out where I am wrong.
-- SET A MARK (RST=1) EVERY TIME PREVIOUS END_DATE IS NOT EQUAL START_DATE
WITH CT AS
(
    SELECT 
        TASK_ID, START_DATE, END_DATE,
        CASE WHEN (COALESCE(LAG(END_DATE) OVER (ORDER BY START_DATE), END_DATE) = START_DATE)
             THEN 0 ELSE 1 END RST
    FROM
        TASK
)
-- SUM(RST) TO SET A GROUP (1, 2, 3, ...)
, CT2 AS
(
    SELECT
        TASK_ID, START_DATE, END_DATE,
        SUM(RST) OVER (ORDER BY START_DATE) AS GRP
    FROM
        CT
)
SELECT 
    MIN(START_DATE) AS START_DATE,
    MAX(END_DATE) AS END_DATE
FROM 
    CT2
GROUP BY
    GRP;




START_DATE          | END_DATE           
:------------------ | :------------------
01/10/2015 00:00:00 | 04/10/2015 00:00:00
13/10/2015 00:00:00 | 15/10/2015 00:00:00
28/10/2015 00:00:00 | 29/10/2015 00:00:00
30/10/2015 00:00:00 | 31/10/2015 00:00:00



db&lt;>fiddle here