I have a table with multiple Street Names with Street Number ranges and date ranges. The problem is that there are some overlapping not only in dates, but in street numbers too, and I need to split it. I saw a question about how to split it by Dates (SQL Server separate overlapping dates), but my problem seems to be slightly different but much more complex.
For Example, this is how it looks right now:
StartDate EndDate StreetName StreetNumberLow StreetNumberHigh Value
2017/1/1 2017/3/31 MyStreet 5 7 1729
2017/4/1 2020/12/31 MyStreet 5 7 1763
2017/1/1 2017/12/31 MyStreet 1 11 1729
2018/1/1 2020/12/31 MyStreet 1 11 18128
How it should look:
StartDate EndDate StreetName StreetNumberLow StreetNumberHigh Value
2017/1/1 2017/3/31 MyStreet 5 7 1729
2017/4/1 2020/12/31 MyStreet 5 7 1763
2017/1/1 2017/12/31 MyStreet 1 4 1729
2017/1/1 2017/12/31 MyStreet 8 11 1729
2018/1/1 2020/12/31 MyStreet 1 4 18128
2018/1/1 2020/12/31 MyStreet 8 11 18128
As you can see, there was two overlaps in Street Number and Dates, so I need to split it. Can someone please help me on finding the solution to this? Thank you
EDITED: Another case example: If I have Street Number range 1 - 11 from January to June with Value 100, and Street Number range 5 - 7 from March to December with Value 200, then the result should be as follows: Street Number range 1 - 11 from January to February with Value 100, Street Number ranges 1 - 4 with Value 100, 5 - 7 with Value 200 and 8 - 11 with Value 100 from March to June, and Street Number range 5 - 7 from July to December with Value 200