quote:
Originally posted by Annie:
I have a table with 2 columns: score and person. I am trying to calculate the person with the highest score. I tried doing:SELECT max(score), person FROM my_table GROUP BY person;
but that results in many returns, not just one. I also tried:
SELECT person FROM my_table WHERE score=max(score);
but that resulted in an error.
Is it possible to find the maximum score and the person associated with that score in one step? Or should I find the score first and then use the WHERE statement in second select statement to get the person that earned it?
Thanks in advance for in help you might be able to offer.
I guess SELECT MAX() is for grouping only.
Try the following query :