user2993884
user2993884

Reputation: 21

Mysql - Select highest by colomn

Feels like this must have been already answered, but I've been looking for a solution for weeks now for no avail. Possible I just don't have the right wording for my issue - apologize.

I have a table (which is the results of another select) that (for the sake of the argument contains two columns:

Name    Salary
Jake     6k
Stephan  8k
Jake     7k
Stephan  5k

Now I want another select to narrow down the table to unique names while keeping only the highest values of Salary:

Name   Salary
Jake     7k
Stephan  8k

Upvotes: 0

Views: 29

Answers (1)

Mureinik
Mureinik

Reputation: 311163

You could use a group by clause on the name:

SELECT   name, MAX(salary)
FROM     mytable
GROUP BY name

Upvotes: 1

Related Questions