SQL Project Planning

  • + 0 comments

    select start_date,end_date from

    (select start_date,x from (select start_date,row_number() over(order by start_date) x from projects where start_date not in (select end_date from projects)) e ) a join

    (select end_date,y from (select end_date,row_number() over(order by end_date) y from projects where end_date not in (select start_date from projects)) t) b on a.x=b.y

    order by Datediff(end_date, start_date), start_date