SQL Challange, Date Merging

time to read 15 min | 2938 words

FromDate ToDate
01/01/2000 31/01/2000
01/02/2000 28/02/2000
05/03/2000 31/03/2000

I have the following table, what must I do to get to this one:

FromDate ToDate
01/01/2000 28/02/2000
05/03/2000 31/03/2000

Basically, the first two date ranges were merge into a single date range because they were adjunct to each other.

Update: It looks like I barely get a chance to post a problem before it is solved. Let try increasing the complexity of this one. Good job, Scott.

Now I want to get all the inclusive date range. So for this data:

FromDate ToDate
01/01/2000 31/01/2000
01/02/2000 28/02/2000
05/03/2000 31/03/2000
01/02/2000 15/02/2000
15/03/2000 15/04/2000

And the result should be:

FromDate ToDate
01/01/2000 28/02/2000
05/03/2000 15/04/2000