I am trying to pull whole record from database for the highest "Score" column.
------------------ ID | Name | Score| ------------------ 1 | john | 10 2 | mark | 20 3 | ted | 15
So when I run
SELECT ID, Name, MAX(Score) FROM TestTable
So I want the query to return entire row 2 because this is the highest value.
This is what I am expecting:
2 | mark | 20
But it does not necessarily return correct row. It always return MAX(Score) but other values are not necessarily from the same row.
This is what I am getting:
3 | ted | 20
Is there a better way of pulling this data? I am using MySQL.
Also I am not interested in sub-query such as
SELECT ID, Name, MAX(Score) FROM TestTable WHERE ID = ( SELECT ID From TestTable WHERE Score = MAX(Score); )
Because I need it for big query using a lot of data, and it needs to perform good.
Please help :)