SQL query problem
July 17, 2009 7:35 AM   Subscribe

I need to write a query that will return the largest value of one column for each unique value in another column. Example included.

Given this table:

NAME SALARY
Smith 5
Smith 22
Adam 55
Jones 12
Jones 10
Smith 21
Smith 4

how would you return one row per NAME with the largest value of SALARY for that name:

NAME SALARY
Adam 55
Jones 12
Smith 22
posted by davcoo to Computers & Internet (2 answers total)
 
Best answer: SELECT name, max(SALARY) from table GROUP BY name;
posted by jacobm at 7:41 AM on July 17, 2009 [2 favorites]


Jacobm has it.
posted by pkphy39 at 8:21 AM on July 17, 2009


« Older You are now old enough to....?   |   Where can I find the educational film called... Newer »
This thread is closed to new comments.