Query syntax help - Query lowest result value per user
I have a database table that contains a varchar field that stores the times players have taken to complete a game. The times are effectively decimals but are stored in the database as varchars. I was given this populated database by my client.
I need to query the database to pull out a list of the top 100 lowest times however I do not want more than one result for any user.
Here is the code that I have tried but it is not working. What it appears to be doing is creating a list of the users who scored the lowest scores in the correct order but not displaying their lowest score.
Note the field fbname is a unique facebook id which identifies unique users.
Can anyone point me in the right direction please
$sql = "SELECT *, MIN(CAST(scoreTime AS DECIMAL( 30, 2 ))) AS f1 FROM score_t GROUP BY fbname ORDER BY f1 LIMIT 0 , 100";