Using DISTINCT to Find Unique Values in MySQL
📖 Scenario: You work at a small bookstore that keeps track of all book sales in a database. Sometimes, you want to find out which unique book titles have been sold, without counting duplicates.
🎯 Goal: Build a simple MySQL query that uses DISTINCT to list unique book titles sold from the sales table.
📋 What You'll Learn
Create a table called
sales with columns id (integer), title (text), and price (decimal).Insert the exact sales data with duplicate book titles as specified.
Write a query using
DISTINCT to select unique book titles from the sales table.Complete the final query to return only the unique titles.
💡 Why This Matters
🌍 Real World
Bookstores and many businesses use DISTINCT to find unique items sold, unique customers, or unique product categories from their sales data.
💼 Career
Knowing how to use DISTINCT is essential for data analysts and database administrators to clean data and generate accurate reports.
Progress0 / 4 steps