Click to See Complete Forum and Search --> : Build Query


rob_sypte
June 6th, 2006, 07:20 AM
With the following sample table:

ID , StartDistance, EndDistance, Date
1, 10, 12, 01/01/2004
2, 8, 11, 01/02/2004
3, 13, 14, 01/01/2004
4, 13, 14, 01/03/2004
5, 17, 25, 01/01/2004
6, 19, 20, 01/02/2004
7, 19, 23, 01/03/2004
8, 20, 23, 01/02/2004

I need to return all rows that don’t overlap (as in cover the same or part or another records inclusive start to end distance) or if they do the record with the latest date will be returned.

So from the sample data I would retun IDs:
2
4
7

I know I can do this using cursors but I'm sure in the back of my head I can do this in a single query but my grey matter is struggling to come up with the answer


Cheers in advance

Rob
:wave: