You can do this using a (correlated) subquery. It's best to work these from the "inside out". First create a query which returns the Sequence number you want (the maximum) for any given ID:
Code:
SELECT MAX(Sequence) FROM YourTable WHERE ID = <a given ID>
Then, you want to select the row, in each subset of rows for a given ID, that has this Sequence (in pseudocode):
Code:
SELECT ID, Sequence, Field1, Field2
FROM YourTable
WHERE ID = <the ID I'm currently on>
AND <the Sequence is a maximum>
Combine the two and correlate the two queries on the ID:
Code:
SELECT ID, Sequence, Field1, Field2
FROM YourTable T1
WHERE Sequence = SELECT MAX(Sequence) FROM YourTable T2 WHERE T1.ID = T2.ID
...should do the trick.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com