I have a simple online leaderboard which also encodes replays in a string. Although the leaderboard stores every laptime reported (currently), the retrieval php just returns the best times for each unique player, thus:
SELECT driver
     , MIN(time)
     , track
     , replay 
  FROM Laptimes 
 WHERE track = '$track'
 GROUP 
    BY driver 
 ORDER 
    BY MIN(time) ASC 
 LIMIT 10
This correctly reports the fastest laptime, but does NOT select the replay associated with that laptime.
Instead you just get the first replay submitted for that driver.
I'm 100% sure the replays are correctly stored in the database, because if I remove the MIN() I get every laptime by every player, and can watch each replay without any problem.
I just can't seem to convince SQL to give me the replay associated with the minimum laptime.
 
     
    