Skip to content

A collection of SQL projects demonstrating expertise in database design, data extraction, transformation, and analytics. Includes real-world use cases such as sales reporting, customer segmentation, and performance tracking. Optimized with joins, CTEs, subqueries, and window functions for efficient data-driven insights.

Notifications You must be signed in to change notification settings

Opelobami/SQL-Projects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 

Repository files navigation

๐Ÿงฎ Retail Sales Analysis

A comprehensive SQL-based retail sales analysis exploring key performance metrics across customer demographics, product categories, sales channels, and profitability.
This project demonstrates strong command of SQL querying, data transformation, and Power BI visualization, transforming raw retail data into insightful business intelligence that drives informed decision-making.


๐Ÿ“˜ Overview

The project focuses on end-to-end analytics; from database creation to dashboard storytelling uncovering performance insights that enhance sales strategy, customer retention, and profit optimization.

Core Objectives:

  • โœ… Create and structure a relational sales database
  • โœ… Import, clean, and transform raw transactional data
  • โœ… Perform exploratory and comparative data analysis
  • โœ… Visualize trends and KPIs in Power BI

The goal is to convert raw retail transactions into business-ready insights for improved decision-making, operational efficiency, and customer experience.


๐Ÿ“Š Dataset

  • Source: Axia SQL Project
  • Key Fields: Transaction ID, Sales Date & Time, COGS, Gender, Category, Quantity, Price per Unit, Total Sales

๐Ÿงฐ Tools & Technologies

  • SQL Server โ€“ Database creation, data manipulation, and exploratory queries
  • Power BI โ€“ Visualization, DAX measures, and report design
  • Excel / CSV โ€“ Source data preparation and validation

๐Ÿ”Ž Analysis Workflow

  1. Database Creation

    • Built the RETAIL_SALES database in SQL Server
    • Structured relational schema for transaction data
  2. Data Importation & Preparation

    • Imported flat-file data into SQL Server
    • Removed null and inconsistent entries
    • Validated data integrity and formatting
  3. Data Transformation & Querying

    • Conducted descriptive, trend, and categorical analysis
    • Queried metrics like total sales, average age, purchase behavior, and sales by category
  4. Visualization in Power BI

    • Imported SQL query results into Power BI
    • Created calculated columns for month and year-based grouping
    • Built reports for executive-level decision support
    • Designed DAX-driven KPIs, monthly performance visuals, and category comparisons

๐ŸงฉSQL Queries

 --1. Write a SQL query to retrieve all columns for sales made on '2022-11-05'
 SELECT*
 FROM [Retail Sales Analysis]
 WHERE sale_date = '2022-11-05';

 --2. Write a SQL query to retrieve all transactions where the category is 'Clothing' and the quantity sold is more than 4 in the month of Nov-2022 
 SELECT*
 FROM [Retail Sales Analysis]
 WHERE sale_date IN ('2022-11-01','2022-11-30')
 AND category ='Clothing' AND quantiy > 4;

 --3. Write a SQL query to calculate the total sales (total_sale) for each category
 SELECT DISTINCT category, SUM(total_sale) AS TotalSale
 FROM [Retail Sales Analysis]
 GROUP BY category
 ORDER BY TotalSale DESC;

 --4. Write a SQL query to find the average age of customers who purchased items from the 'Beauty' category
 SELECT AVG(age) AS Customers_Avg_Age
 FROM [Retail Sales Analysis]
 WHERE category = 'Beauty'

--5. Write a SQL query to find all transactions where the total_sale is greater than 1000
 SELECT*
 FROM [Retail Sales Analysis]
 WHERE total_sale > 1000

 --6. Write a SQL query to find the total number of transactions (transaction_id) made by each gender in each category
 SELECT category, gender, COUNT(transactions_id) AS total_transaction 
 FROM [Retail Sales Analysis]
 GROUP BY category, gender
 ORDER BY total_transaction DESC;

--7. Write a SQL query to calculate the average sale for each month. Find out best-selling month in each year .
 SELECT YEAR(sale_date) AS Sales_Year, MONTH(sale_date) AS Sales_Month, AVG(total_sale) AS Avg_monthly_sales
 FROM [Retail Sales Analysis]
 GROUP BY YEAR(sale_date), MONTH(sale_date)
 ORDER BY Sales_Year, Sales_Month, Avg_monthly_sales;

--8. Write a SQL query to find the top 5 customers based on the highest total sales.
 SELECT Top 5 customer_id,  SUM(total_sale) AS Highest_Sales
 FROM [Retail Sales Analysis]
 GROUP BY customer_id
 ORDER BY Highest_Sales DESC;

--9. Write a SQL query to find the number of unique customers who purchased items from each category.
 SELECT category, COUNT(DISTINCT customer_id) AS Customers
 FROM [Retail Sales Analysis]
 GROUP BY category
 ORDER BY Customers DESC;

--10. Write a SQL query to create each shift and number of orders (Example Morning <12, Afternoon Between 12 & 17, Evening >17) 
 SELECT CASE 
 WHEN DATEPART(HOUR, sale_time) < 12 THEN 'Morning'
 WHEN DATEPART(HOUR, sale_time) BETWEEN 12 AND 17 THEN 'Afternoon'
 ELSE 'Evening'
 END AS Shift,
 COUNT(*) AS Number_of_Orders
 FROM [Retail Sales Analysis]
 GROUP BY CASE 
 WHEN DATEPART(HOUR, sale_time) < 12 THEN 'Morning'
 WHEN DATEPART(HOUR, sale_time) BETWEEN 12 AND 17 THEN 'Afternoon'
 ELSE 'Evening'
 END;

๐Ÿ‘‰ [View Interactive Power BI Dashboard โ†’] (https://app.powerbi.com/view?r=eyJrIjoiYzdjZjM4OGYtNzlmOS00ODdkLWI1YjMtZmRiNGM4NzViNzRjIiwidCI6ImRkYjk1YzMwLWU3OWUtNDdiNy05YTVmLWE0MmNkZDljOTk5ZCJ9)


๐Ÿ’ก Key Insights

  • ๐Ÿ’ฐ โ‚ฆ908K Total Sales generated across all categories
  • ๐ŸŒ† 53.45% of orders occurred in the evening
  • ๐Ÿ‘ฅ Average customer age: 41.35 years
  • ๐Ÿงโ€โ™‚๏ธ Top Customer: ID 3 with โ‚ฆ38K in purchases
  • ๐Ÿ–ฅ๏ธ Electronics sales outperform Clothing by 0.3% and Beauty by 8.4%
  • ๐Ÿ“… 2023 outperformed 2022 in total sales (โ‚ฆ459K vs โ‚ฆ449K) and customer count (1,021 vs 966)

The dashboard provides:

  • Real-time tracking of sales performance and customer engagement
  • Category-level profitability and product contribution
  • Time-series visualizations for trend and seasonal analysis
  • Interactive filters and KPIs for dynamic insight exploration

๐Ÿงฉ Insights Summary

This analysis reveals a healthy retail operation with strong customer diversity and consistent sales growth. However, performance gaps exist across certain product lines and sales periods.

Highlights:

  • Electronics dominate category revenue
  • Evening transactions represent over half of all sales
  • 2023 saw growth in both total sales and customer base but decline in average monthly sales.

๐ŸŽฏ Recommendations

  1. Category Optimization:

    • Increase marketing investment in high-performing categories (Electronics)
    • Reevaluate underperforming product lines for pricing or promotion adjustments
  2. Customer Retention:

    • Target repeat customers (especially high-value IDs) with loyalty programs
  3. Time-based Strategy:

    • Extend promotions to align with evening purchase peaks
  4. Advanced Forecasting:

    • Use SQL and Power BI time-intelligence DAX for future demand forecasting
  5. Operational Efficiency:

    • Establish an automated data refresh schedule to keep Power BI insights real-time

๐Ÿง  Key Learning & Impact

This project demonstrates expertise in:

  • Translating business problems into SQL queries
  • Designing data pipelines from raw import to interactive visualization
  • Communicating insights that directly influence revenue and strategy decisions

It reflects a strong foundation in data analytics, storytelling, and technical execution essential for real-world BI and data roles.


๐Ÿ“ฌ Contact

If youโ€™re looking for a data-driven problem solver who can turn complex datasets into actionable stories, letโ€™s connect:


โœจ Transforming raw data into meaningful business intelligence; one query at a time.

About

A collection of SQL projects demonstrating expertise in database design, data extraction, transformation, and analytics. Includes real-world use cases such as sales reporting, customer segmentation, and performance tracking. Optimized with joins, CTEs, subqueries, and window functions for efficient data-driven insights.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published