Part 21: Sorting Results with ORDER BY (ASC vs DESC)
In relational theory, table rows have no inherent order. To guarantee the order of your query results, you must use ORDER BY.
1. Ascending and Descending Sorts
ASC(default): Smallest to largest / Alphabetical A-Z.DESC: Largest to smallest / Reverse alphabetical Z-A.
SELECT product_name, price
FROM products
ORDER BY price DESC;
Key Takeaways
- Relational databases return unordered sets unless
ORDER BYis explicitly defined. - Default sort order is
ASC.
In Part 22, we explore Multi-Column Sorting & Sorting by Expressions!

