Order query results ascending or descending.
Section: Sorting and Limiting
Sort rows
sql
sql
SELECT id, created_at
FROM orders
ORDER BY created_at DESC, id ASC;Explanation
ORDER BY is applied after filtering and grouping.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Sorting and Limiting