Live SQLite 3.54 Sandbox
SQL ORDER BY & LIMIT (with live sandbox)
ORDER BY sorts query rows ascending (ASC) or descending (DESC), and LIMIT caps output to the top N rows.
Syntax
SELECT col1, col2 FROM table_name ORDER BY col2 DESC LIMIT 5;Return the top 3 highest-value orders (order_id, amount) sorted by amount DESC.
SQLite 3.50 SandboxCtrl/Cmd + Enter to Run (unlimited & ungraded)
Practise ORDER BY & LIMIT in our free SQL track
Same streak & XP across Excel, Google Sheets, and SQL.
Free 1-Page Excel, Google Sheets & SQL Interview Cheat Sheet
The 25 formulas, keyboard shortcuts, and SQL patterns tested most in analyst interviews — emailed instantly, zero spam.