Question : query help

having difficulty with a query
lets say a table contains the following
acctnbr      transkey
100      5
100      4
100      7
101      6
101      5
102      5
102      6
102      7

i need a query that returns just one record for each acctnbr and that has the max value for transkey
for this example the results would be
100      7
101      6
102      7

thanks ...

Answer : query help

If you need other fields in the table, and assuming transkey is unique for each acctnbr

select a.acctnbr, a.transkey, a.col1, a.col2, ...
from
(
select acctnbr, max(transkey) as maxkey
from tbl
group by acctnbr
) X inner join tbl a on a.acctnbr=X.acctnbr and a.transkey=X.maxkey
Random Solutions  
 
programming4us programming4us