Reputation: 5413
I have a set of players and I want to select the top 5 scores from the tables and print out the username and scores in descending order, what's the SQL statement for that? and How to output the result?
Upvotes: 0
Views: 572
Reputation: 2358
SELECT * FROM yourtable ORDER BY score DESC LIMIT 5
Explanations:
SELECT * FROM yourtable
: we select yourtable
.
ORDER BY score DESC
: We order the results based on the column score
and in descending order.
LIMIT 5
: we limit the number of results by 5.
Upvotes: 1