Hey All,
I am having a bit of challenge...I have a data set which resembles the first table below. I am attempting to group records where ID1 and ID2 are the same and where date ranges that are consecutive and/or fall within the consecutive range are grouped. All of the relevant data elements (financials etc) would be summed/grouped as well. I have spent a considerable amount of time on this and I'm quite stumped. Any help that you could provide would be great!
ID1 is always the same for each series of dates. ID2 can be different. The table below represents one example of ID1
Thanks!
Here is a sample data set:
ID1 ID2 Admit Date Discharge Date
0001 000 7/23/2013 7/25/2013
0001 001 9/20/2013 9/21/2013
0001 001 9/21/2013 10/11/2013
0001 001 10/11/2013 11/15/2016
0001 001 10/16/2013 10/18/2013 this one runs concurrently or 'falls within' the consecutive range
0001 001 11/15/2013 12/04/2013
0001 001 12/4/2013 12/09/2013
0001 001 12/9/2013 12/18/2013
0001 001 12/22/2013 12/23/2013
What it should look like when the query is ran:
ID1 ID2 Admit Date Discharge Date
0001 000 7/23/2013 7/25/2013
0001 001 9/20/2013 12/18/2013
0001 001 12/22/2013 12/23/2013