Sales Trend Analysis Using Aggregations
This repository contains a SQL project based on a fictional Chocolate Sales dataset. The project focuses on data cleaning, type conversion, aggregation, and reporting using SQL queries in MySQL.
chocolate_sales.sqlβ SQL script to create, populate, and manage thechocolate_salestable.
The dataset includes the following columns:
| Column Name | Description |
|---|---|
Sales Person |
Name of the salesperson |
Country |
Country where the sale happened |
Product |
Type of chocolate sold |
Date |
Date of the sale (format: dd-mmm-yy) |
Amount |
Sale amount (formatted with $ and ,) |
Boxes Shipped |
Number of boxes shipped |
-
Data Cleaning
- Converted
Amountcolumn from text to numeric by removing$and,. - Converted
Datecolumn into properDATEformat.
- Converted
-
Schema Alteration
- Changed the datatype of
AmounttoDECIMAL(10,2).
- Changed the datatype of
-
Aggregate Queries
- Total and average sales by country, product, and salesperson.
- Monthly revenue summaries.
- Top 3 products by sales.
-
Safe Update Handling
- Handled
Error Code: 1175by disabling safe update mode for bulk updates.
- Handled
Top 3 Products by Sales
SELECT Product, SUM(Amount) AS Total_Sales
FROM chocolate_sales
GROUP BY Product
ORDER BY Total_Sales DESC
LIMIT 3;