SQL Data Analytics • Lesson 5
Sorting & Limiting Data
Learn how to organize query results using ORDER BY, choose a direction with ASC or DESC, and return only the rows you need with LIMIT or TOP.
0 of 8 concepts completed
Complete the activity and related MCQ to unlock the next concept.
ORDER BY Sorts Results
By default, SQL does not guarantee the order of rows. ORDER BY lets you explicitly sort the result so the analysis is predictable and useful.
Interactive Data
Products table
We will use this Products dataset throughout the lesson to sort, predict and limit query results.
| product_id | product | category | price |
|---|---|---|---|
| 101 | Laptop | Electronics | ₹50,000 |
| 102 | Mouse | Electronics | ₹1,200 |
| 103 | Chair | Furniture | ₹8,000 |
| 104 | Desk | Furniture | ₹15,000 |
| 105 | Keyboard | Electronics | ₹2,500 |
| 106 | Monitor | Electronics | ₹18,000 |
| 107 | Lamp | Furniture | ₹900 |
| 108 | Tablet | Electronics | ₹22,000 |
Learn by Seeing
Sort products by price
SELECT * FROM Products ORDER BY price;
ORDER BY price sorts the products from the lowest price to the highest price.
Unsorted
ORDER BY price ASC
Interactive Activity
Choose the product that appears first when sorting by price ascending.
Hint: Ascending order starts with the smallest value. Which product has the lowest price?
SQL Analyst Mindset
Sort first, then limit
Analysts use ORDER BY and LIMIT together to answer "top N" business questions: top customers, best-selling products, worst-performing regions, and more.
Understand
Which metric matters most?
Sort
Highest first or lowest first?
Limit
How many rows does the business need?
Validate
Do the rows answer the question?
Lesson Summary
What you learned
Sort query results.
Choose sort direction.
Restrict the number of rows returned.
Dialect differences between databases.
Frequently Asked Questions