SQL Project Planning

  • + 0 comments

    with t1 as( select start_date, end_date, row_number() over (order by end_date) as rn from projects)

    select sd, ed from ( select min(start_date) as sd, max(end_date) as ed, count(*) as cnt from ( select start_date, end_date, date_sub(end_date, interval rn day) as flag_date from t1) a group by flag_date ) b order by cnt, sd