Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for How I Analyzed Retail Sales Data Using SQL
Akanle Tolulope
Akanle Tolulope

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

  1. View all sales transactions with product names and total sale amounts
  2. Calculate total quantity sold and total revenue per product
  3. Compute average quantity sold per product
  4. Identify products with total revenue above 3,000
  5. 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)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

An aspiring techie, ready to learn and develop myself
  • Joined

More fromAkanle Tolulope

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp