Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    Akld, NZ
    Posts
    38

    Question Unanswered: Select the row with the highest number

    Hi all,

    Hopefully you can assist this pleb (me) with some (hopefully) basic scripting.

    I have a table which has bucket loads of rows in it (funnily enough)
    Field1 & Field2
    Field1 is repeated numerous times (but also has differing values) through the table
    Field2 is a numeric value which is assigned to the Field1

    What I need to do is pull back all the unique Field1's but only those with the highest value in Field2

    Example:
    Field1 Field2
    blah 100
    blah 400
    blah1 12
    blah1 9
    blah1 2
    blah 350

    I need the return to be basically:

    Field1 Field2
    blah 400
    blah1 12

    I am sure that this has to be straight forward - however my brain just isn't connected the right way at the moment....

    Thanks in advance for any assistance on this.

    Troy
    Sideways see's more scenery

  2. #2
    Join Date
    Oct 2003
    Posts
    268
    SELECT Field1, MAX(Field2) FROM Table GROUP BY Field1

  3. #3
    Join Date
    Nov 2003
    Location
    Akld, NZ
    Posts
    38

    Red face

    damn I new it was going to be painfully straight forward

    Thanks!
    *shrinks away into the corner*
    Sideways see's more scenery

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •