Skip to content
Advertisement

Eliminate and reduce overlapping date ranges

I have a set of date ranges consisting of both partially and fully overlapping dates, like this:

Using T-SQL, I would like to create a new set of data, per user, with eliminated overlapping data, extending ranges and removing redundant data where needed, resulting in something like this:

Cursors are fine if needed, but if I can do without them that would be even better.

Advertisement

Answer

For SQL Server 2005+

Notes:

  1. Replace @t with your table name
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement