I have two tables
User
id
name
Result
id
user_id
score
created_at
Every hour a cron job runs and puts data in the result table for each user - assigning them a score based on some external variable parameters.
So the Result table contains many records for each user.
I want to retreive a 'top ten' users at any given point. So only one row for each user should be returned, and it should contain their most recent available score, and ideally only 10 rows relating to those ten users with the highest scores.
I currently fetch all results and do the leg work with php which I'm fairly sure would be faster and more efficient if handled by the database. But I don't know where to start.