The ORDER BY clause sorts query results by one or more columns. You can sort ascending (ASC) or descending (DESC), and chain multiple columns to set precedence.
// Syntax for ORDER BY: select columns and specify sorting directions
SELECT column1, column2
FROM table_name
ORDER BY column1 [ASC|DESC], column2 [ASC|DESC];
// Select all students and order by age in ascending order
SELECT * FROM students
ORDER BY age ASC;
// Select students and order by department (asc) then age (desc)
SELECT * FROM students
ORDER BY department ASC, age DESC;
Imagine a students table — sorting by age ASC will list youngest students first; department ASC, age DESC groups by department, and within each department shows the oldest students first.
ASC or DESC when you need a particular order; otherwise ASC is default.ORDER BY with LIMIT to get top/bottom results efficiently.students table and order by name in descending order.department, then age.