
Posted on • Edited on
How I Analyzed Retail Sales Data Using SQL
Hello everyone, it's me again. Today I’m excited to share another practical project I worked on to strengthen my SQL and data analysis skills: a retail sales data analysis built entirely with SQL!
**
Now lets look at Why Sales Data Analysis is Important **
Retail businesses rely heavily on sales data to track product performance, monitor revenue growth, and make informed business decisions. As a data analyst, the ability to efficiently query and summarize sales data is a must-have skill—which this project allowed me to practice.
** Project Overview **
I created a simple retail sales database consisting of two tables:
- Products: Contains product details like name, category, and unit price.
- Sales: Records sales transactions, including product ID, quantity sold, and sale date.
From there, I wrote SQL queries to answer critical business questions such as
- What’s the total quantity sold and revenue for each product?
- What’s the average quantity sold per product?
- Which products generated revenue above a target threshold?
- Which product was the top seller by total revenue?
*Tools and Skills Used *
- SQL (DDL, DML, Aggregate functions, HAVING, JOIN, Subqueries)**
- GitHub for project hosting and code management
** Tables I Created **
CREATE TABLE Products(
ProductID INT PRIMARY KEY,
ProductName VARCHAR(50),
Category VARCHAR(50),
UnitPrice DECIMAL(10, 2)
);
CREATE TABLE Sales(
SalesID INT PRIMARY KEY,
ProductID INT,
Quantity INT,
SaleDate DATE
);
Then i inserted values into these tables using 'INSERT INTO'
Key Queries and Insights
- View all sales transactions with product names and total sale amounts
- Calculate total quantity sold and total revenue per product
- Compute average quantity sold per product
- Identify products with total revenue above 3,000
- Find the product with the highest total sales revenue
Example: SELECT ProductName, SUM(S.Quantity) AS total_quantity_sold,
SUM(S.Quantity * P.UnitPrice) AS total_revenue
FROM Sales S
JOIN Products P ON S.ProductID = P.ProductID
GROUP BY ProductName
ORDER BY total_revenue DESC;
Lessons I Learned
SQL aggregate functions are powerful tools for summarizing business data.
Always double-check your JOIN conditions when combining tables.
Subqueries can simplify complex logic if structured correctly.
Project Link
Check out the full project and SQL scripts on GitHub:
https://github.com/Akansrodger/retail-sales-data-analysis-sql
Final Thoughts
This was a rewarding small project that reinforced core SQL skills and demonstrated how straightforward queries can provide valuable business insights.
I recommend similar practical projects to anyone starting out in SQL or data analysis; you’ll gain useful skills fast and have solid portfolio material to show for it.
If you found this useful, check out my Hospital Patient Management System SQL project too.
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse