Advertise here: Contact FM.


SQL query problem
July 17, 2009 7:35 AM   RSS feed for this thread 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 comments total)
SELECT name, max(SALARY) from table GROUP BY name;
posted by jacobm at 7:41 AM on July 17 [2 favorites]


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


« Older Make the birthday cards I send...   |   Where can I find the education... Newer »

You are not logged in, either login or create an account to post comments