Services Work Learn About Contact
0/9
Lesson 6 of 9

ORDER BY & LIMIT

ORDER BY sorts results. Use ASC for ascending (A-Z, 0-9) or DESC for descending. LIMIT restricts how many rows are returned.

SQL
-- Sort by price lowest to highest
SELECT * FROM products ORDER BY price ASC;

-- Sort by newest first
SELECT * FROM orders ORDER BY created_at DESC;

-- Get top 5 most expensive
SELECT * FROM products ORDER BY price DESC LIMIT 5;
🧠

Quick Quiz

Answer correctly to unlock the next lesson.

Support the mission

This learning platform is 100% free: no ads, no tracking, no paywalls. If it helped you learn something useful, you can support future lessons or donate to Doctors Without Borders, which provides emergency medical care in crisis zones worldwide.

🎉

You completed SQL!

You finished all 9 lessons and quizzes. You now know the basics of SQL.