Overlap in ranges.I have a set of data,rows which a start_time and a end_time.Each row should get a New_starttime, so that periods do not overlap.A period can not be split into two periods.Example:[code="sql"]Periods (overlapping):----1111111111-----------------------------------------------2222-------------------------------------------------------333333333---------------------------------Periods with a New_startime, removing overlaps.----1111111111---------------------------------------- New_starttime is equal to starttime------------------------------------------------------ New_starttime is equal to endtime--------------3333333--------------------------------- New-starttime is equal to endtime of 1[/code]In this example the first period is kept 'complete'.The second period effectively gets a duration of 0.The third period get a new starttime and is effectively shortened.-- See also the thread :-- http://www.sqlservercentral.com/Forums/Topic1760478-3412-1.aspxI have looked at that thread and am still working on it. I think that that is a good starting point, for both a set of sample data and a solution. I am posting this problem here, because their might allready be a 'canned' solution for this or this may be an interresting problem. I'll be working on the/a solution myself, I think I can come up with something.So the question is the number of rows should remain the same, but with the New_starttime the overlap should be removed from the periods.Thanks for your time and attention.A solution which also works in 2005/2008 is preverred.BenEdit:The example uses periods which start and end exactly on a date.In my situation the periods start and end on a exact 'time'.Overlap is then defined as a overlapping period. (The overlap period large (a day) or very small (a microsecond), same times do not overlap.)Sorry I missed this when posting this for the first time.
↧