Filtering and Sorting Sales Data with SELECT, WHERE, ORDER BY, and GROUP BY
📖 Scenario: You work as a data analyst for a retail company. You have a sales database table that records each sale with the product name, category, quantity sold, and sale date. Your manager wants you to find specific sales data by filtering, sorting, and grouping the sales records.
🎯 Goal: Build SQL queries step-by-step to filter sales by category, sort them by quantity, and group sales by product to find total quantities sold.
📋 What You'll Learn
Create a table called
sales with columns product (text), category (text), quantity (integer), and sale_date (date).Write a SELECT query to get all sales where the category is exactly 'Electronics'.
Add an ORDER BY clause to sort the filtered sales by
quantity in descending order.Write a GROUP BY query to find total quantity sold per product.
💡 Why This Matters
🌍 Real World
Filtering, sorting, and grouping data are common tasks in analyzing sales, inventory, or customer data in businesses.
💼 Career
Database querying skills with SELECT, WHERE, ORDER BY, and GROUP BY are essential for data analysts, database administrators, and backend developers.
Progress0 / 4 steps