Using GROUP BY on a Single Column in SQL
📖 Scenario: You work at a small bookstore. You have a table that records every book sale with the book's genre and the number of copies sold. You want to find out how many copies were sold for each genre.
🎯 Goal: Create an SQL query that groups the sales by the genre column and sums the copies_sold for each genre.
📋 What You'll Learn
Create a table called
book_sales with columns genre (text) and copies_sold (integer).Insert the exact rows given into
book_sales.Write a query that groups the data by
genre and sums copies_sold.Order the results by
genre alphabetically.💡 Why This Matters
🌍 Real World
Grouping sales data by category helps businesses understand which categories perform best.
💼 Career
Data analysts and database developers often use GROUP BY to summarize data for reports.
Progress0 / 4 steps