I have a set of players and I want to select the top 5 scores 开发者_Python百科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?
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.
精彩评论