I am using T-SQL (Microsoft SQL Server Management Studio 2017) and I have a data set that resembles the following:
BEGINDATE ENDDATE ID
2015-07-01 2015-07-12 1
2015-07-01 2015-07-12 1
2015-07-11 2015-07-15 1
2015-07-18 2015-08-04 1
2015-06-28 2015-07-04 2
2015-06-28 2015-07-03 2
2015-06-29 2015-07-04 2
2015-07-03 2015-07-15 2
2015-07-17 2015-07-20 2
What I would like to do is to merge overlapping dates by ID (There are a few examples out there that do this but not by group - like this one).
Ideally, the end result would be something like:
BEGINDATE ENDDATE ID
2015-07-01 2015-07-15 1
2015-07-18 2015-08-04 1
2015-06-28 2015-07-15 2
2015-07-17 2015-07-20 2
Any suggestions?