This project performs an end-to-end analysis of retail sales data using MySQL. The objective is to clean the data, explore key patterns, and answer practical business questions using SQL.
This project focuses on applying SQL concepts to real-world scenarios such as customer behavior, sales trends, and time-based analysis.
Note: This project was created with guidance from an online tutorial (YouTube) for learning purposes.
All SQL queries were written, executed, and understood independently as hands-on practice.
The dataset contains transactional retail sales data with the following columns:
- transaction_id
- sale_date
- sale_time
- customer_id
- gender
- age
- category
- quantity
- price_per_unit
- cogs
- total_sale
The raw dataset is included in the data/ folder of this repository.
The following data-cleaning steps were performed using SQL:
- Identified NULL values across all columns
- Removed rows containing missing values to ensure consistency and accuracy
- Verified record counts after cleaning
Initial analysis was performed to understand the dataset structure and key metrics:
- Total number of sales transactions
- Number of unique customers
- Number of unique product categories
This project answers the following business-driven questions:
- Retrieve all sales made on a specific date
- Identify Clothing category transactions with high quantity sold in November 2022
- Calculate total sales for each product category
- Find the average age of customers purchasing from the Beauty category
- Retrieve all transactions with total sales greater than 1000
- Analyze the number of transactions by gender and category
- Identify the best-selling month in each year using window functions
- Find the top 5 customers based on total sales
- Determine the number of unique customers per category
- Analyze order distribution by time of day (Morning / Afternoon / Evening)
- MySQL
- SQL Aggregations (
SUM,AVG,COUNT) GROUP BYandHAVINGCASEstatements- Date & time functions
- Subqueries
- Window functions (
RANK())
- Writing clean and readable SQL queries
- Applying SQL to real business scenarios
- Understanding execution order in SQL
- Using window functions for ranking and trend analysis
- Structuring SQL projects for portfolio presentation
retail-sales-analysis-sql/
βββ data/
β βββ retail_sales_analysis_raw.csv
βββ sql/
β βββ retail_sales_project.sql
βββ README.md