my table lools like this:
name | var
----------------
Joe | 3
Liz | 1
Liz | 4
Joe | 2
Peter | 3
Joe | 7
Liz | 2
I am looking for a MYSQL query that will give me the DISCTINCT names of column name
with the highest var
related to the name
.
So, for the example above, I am looking for
Joe | 7
Liz | 4
Peter | 3
my try was:
SELECT name, var
FROM table
GROUP BY name
ORDER BY var DESC
I tried, too,
SELECT DISTINCT name, var
or
SELECT DISTINCT(name), var
but with those I got distinct combinations of name,var