Sorting Data with ASC and DESC in SQL
📖 Scenario: You are managing a small bookstore database. You want to organize the list of books by their prices to help customers find the cheapest or most expensive books easily.
🎯 Goal: Build SQL queries that sort the books by price in ascending and descending order using ASC and DESC.
📋 What You'll Learn
Create a table called
books with columns id, title, and price.Insert exactly three books with specified titles and prices.
Write a query to select all books sorted by
price in ascending order using ASC.Write a query to select all books sorted by
price in descending order using DESC.💡 Why This Matters
🌍 Real World
Sorting data is essential in databases to organize information for reports, user views, or analytics. For example, customers often want to see products from cheapest to most expensive.
💼 Career
Database developers and analysts frequently write queries with sorting to prepare data for applications, dashboards, or decision-making.
Progress0 / 4 steps