sqlselectfindrow

How to find rows which have highest value of specific column


For example, the table has columns MYINDEX and NAME.

MYINDEX | NAME
=================
1       | BOB
2       | BOB
3       | CHARLES

Ho do I find row with highest MYINDEX for specific NAME? E.g. I want to find ROW-2 for name "BOB".


Solution

  • SELECT Max(MYINDEX) FROM table WHERE NAME = [insertNameHere]

    EDIT: to get the whole row:

    Select * //never do this really
    From Table
    Where MYINDEX = (Select Max(MYINDEX) From Table Where Name = [InsertNameHere]