tripleblep
tripleblep

Reputation: 540

Getting User with Highest Amount

I have a table full of users and, using the below query, I'm able to get the result of the highest score divided by points:

SELECT MAX(points/score) FROM table

However, I'd like to grab the user associated with the result; any suggestions?

Upvotes: 1

Views: 57

Answers (2)

oezi
oezi

Reputation: 51807

just order by points/score and limit the result to one:

SELECT
  *
FROM
  table
ORDER BY
  points/score DESC
LIMIT 1

Upvotes: 1

Imre L
Imre L

Reputation: 6249

SELECT * 
  FROM table
 ORDER BY points/score DESC
 LIMIT 1

Upvotes: 3

Related Questions