Query to get the Max record for each ID

  • I have a table that has dozens of records for each identifier. I need to get one record for each identifier, and the record has to be the one with the maximum value in one of the fields:

    e.g.

    ID VALUE

    1 5

    1 7

    1 4

    2 2

    2 4

    2 6

    I'd only want to return 1/7 and 2/6 in the result set. Any thoughts on how to do this? Thanks.

  • Select max(value) Val, Id from tblname group by Id :hehe:

  • well that is surprising simple, I feel kind of stupid. Thank you.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply