Why ordering organizes results
📖 Scenario: You work at a bookstore that keeps track of book sales in a database table called sales. Each sale record has the book_title and the copies_sold. You want to see the sales data sorted to understand which books sell the most and which sell the least.
🎯 Goal: Build a SQL query that retrieves all sales records and orders them by the number of copies sold, from highest to lowest.
📋 What You'll Learn
Create a table called
sales with columns book_title (VARCHAR) and copies_sold (INT).Insert exactly these three rows into
sales: ('The Alchemist', 150), ('1984', 200), ('The Hobbit', 120).Write a SQL query that selects all columns from
sales and orders the results by copies_sold in descending order.Ensure the final query uses
ORDER BY copies_sold DESC.💡 Why This Matters
🌍 Real World
Ordering query results helps businesses quickly see top-selling products or important data sorted by priority.
💼 Career
Database developers and analysts use ORDER BY to organize data reports and dashboards for decision making.
Progress0 / 4 steps