I'm not sure how to interprete the plan for yours....mine has less to do though..CREATE TABLE myTable99([ID] varchar(20), [start_date] datetime, end_date datetime, PRIMARY KEY ([ID], [start_date]))GOINSERT INTO myTable99 ([ID], [start_date], [end_date])SELECT '03T035', '2000-06-01 00:00:00', '2000-10-03 00:00:00' UNION ALLSELECT '03T035', '2000-10-04 00:00:00', '2000-10-05 00:00:00' UNION ALLSELECT '03T035', '2001-06-01 00:00:00', '2045-12-31 00:00:00' UNION ALLSELECT '053026', '1985-04-01 00:00:00', '1986-03-31 00:00:00' UNION ALLSELECT '053026', '1986-04-01 00:00:00', '1987-03-31 00:00:00'GOSELECT * FROM myTable99 o WHERE EXISTS ( SELECT [ID] FROM myTable99 i WHERE i.[ID] = o.[ID] GROUP BY [ID] HAVING MAX(i.[start_date]) = o.[start_date]) SELECT ID, start_date, end_dateFROM(SELECT ROW_NUMBER() OVER (PARTITION BY ID ORDER BY start_Date DESC) AS Seq,*FROM myTable99)tWHERE Seq=1 DROP TABLE myTable99GO
Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspx