Using GROUP BY Clause in MySQL
📖 Scenario: You work for a small bookstore that wants to analyze sales data.The store keeps a record of each sale with the book title and the number of copies sold.
🎯 Goal: Create a MySQL query that groups sales by book title and calculates the total copies sold for each book.
📋 What You'll Learn
Create a table called
sales with columns book_title (VARCHAR) and copies_sold (INT).Insert the exact sales data given.
Write a query that uses
GROUP BY book_title to sum copies_sold for each book.Order the results by total copies sold in descending order.
💡 Why This Matters
🌍 Real World
Grouping and summarizing sales data helps businesses understand which products sell best.
💼 Career
Database analysts and developers use GROUP BY queries to generate reports and insights from data.
Progress0 / 4 steps