Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Identify overlapping segments with same id

Author  Topic 

sqlserver_newbee
Starting Member

11 Posts

Posted - 2008-10-14 : 14:33:34
ID Start_Date End_Date PRoll
--------------------------------------------------------------------------
1 02-03-2007 02-03-2008 1A
1 03-31-2008 12-12-2008 1C
2 01-01-2008 04-25-2008 2A
2 03-03-2008 10-21-2008 2B
3 05-06-2007 08-01-2007 3A
3 08-08-2007 08-08-2008 3B


I have a set like above where each id has multiple segments. I want to get all the ids where the segments are overlapping. For example ID 2 where End_Date on first segments is > Start Date of second segment. The dataset is sorted on ID, Start and End Date.

I am not able to come with the best way of finding overlapping segments for each id. I appreciate all your suggestions!

Thanks!

PS - I just realized I posted the question in SQL Server Development instead of Transact-SQL forum. Sorry for multiple posts admin team.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-14 : 15:24:09
Cross posting http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=112549



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -