Why Aggregation Summarizes Data
📖 Scenario: You work at a small bookstore. You have a table that records each sale with the book title and the number of copies sold. You want to understand the total sales for each book to see which books sell the most.
🎯 Goal: Build a simple database query that uses aggregation to summarize total sales per book.
📋 What You'll Learn
Create a table called
sales with columns book_title (text) and copies_sold (integer).Insert these exact rows into
sales: ('The Hobbit', 3), ('1984', 5), ('The Hobbit', 2), ('Dune', 4), ('1984', 1).Write a query that uses
GROUP BY on book_title and SUM(copies_sold) to find total copies sold per book.Order the results by total copies sold in descending order.
💡 Why This Matters
🌍 Real World
Aggregations help businesses quickly understand total sales, averages, or counts from many records, making it easier to make decisions.
💼 Career
Database aggregation queries are essential skills for data analysts, business intelligence developers, and anyone working with data to summarize and report information.
Progress0 / 4 steps