My table structure is below:
Name email score time
Hello abc@gmail.com 100 15
Hello abc@gmail.com 58 10
Test def@gmail.com 100 12
Stack xyz@gmail.com 90 20
Test def@gmail.com 50 40
Using select query
$q="SELECT name, MAX(score) as score ,email FROM users GROUP BY email ORDER BY MAX(score) DESC LIMIT 10";
Below result generates.
Name email score time
Hello abc@gmail.com 100 15
Test def@gmail.com 100 12
Stack xyz@gmail.com 90 20
What I am confused is, if two user have same score, I want to sort the result based on lowest time, since "Test" user scored 100 in 12 seconds, it should come first.