I\'m trying to select only the row with the highest seq for each ID
ID | Seq | Age
-------------------
A 1 20
A 2 30
B
In general, you neeed to use windowing or ranking functions - Rank(), Row_number(), etc.
select *
from
(
select *, row_number() over (partition by id order by age desc) rn
from yourtable
) v
where rn = 1
This will work in SQL Server 2005+ - in oracle you may need to specify the field names explicitly, instead of the *