TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst ยท 76.7K subscribers
Post #2571 2.39K
๐Ÿš€ SQL Project Series #1

E-Commerce Sales Analysis Project ๐Ÿ›’

Build a real-world SQL project from scratch and learn the SQL skills required for Data Analyst interviews.

๐ŸŽฏ Business Objectives

โœ… Analyze total sales and revenue

โœ… Identify top-selling products

โœ… Find the best-performing product categories

โœ… Calculate monthly sales trends

โœ… Identify repeat customers

โœ… Find inactive customers

โœ… Calculate Average Order Value (AOV)

โœ… Calculate Customer Lifetime Value (CLV)

โœ… Analyze customer purchasing behavior

๐Ÿ“‚ Step 1: Create Database

CREATE DATABASE ecommerce_db;

USE ecommerce_db;

๐Ÿ“‚ Step 2: Create Customers Table

CREATE TABLE customers (

customer_id INT PRIMARY KEY,

customer_name VARCHAR(100),

gender VARCHAR(10),

city VARCHAR(50),

signup_date DATE

);

๐Ÿ“‚ Step 3: Create Products Table

CREATE TABLE products (

product_id INT PRIMARY KEY,

product_name VARCHAR(100),

category VARCHAR(50),

price DECIMAL(10,2)

);

๐Ÿ“‚ Step 4: Create Orders Table

CREATE TABLE orders (

order_id INT PRIMARY KEY,

customer_id INT,

order_date DATE,

order_status VARCHAR(30),

FOREIGN KEY (customer_id)

REFERENCES customers(customer_id)

);

๐Ÿ“‚ Step 5: Create Order_Items Table

CREATE TABLE order_items (

order_item_id INT PRIMARY KEY,

order_id INT,

product_id INT,

quantity INT,

unit_price DECIMAL(10,2),

FOREIGN KEY (order_id)

REFERENCES orders(order_id),

FOREIGN KEY (product_id)

REFERENCES products(product_id)

);

๐Ÿ“‚ Step 6: Insert Sample Customers

INSERT INTO customers VALUES

(1,'Rahul','Male','Mumbai','2025-01-10'),

(2,'Priya','Female','Delhi','2025-01-15'),

(3,'Amit','Male','Pune','2025-02-01'),

(4,'Sneha','Female','Bangalore','2025-02-10'),

(5,'Rohan','Male','Hyderabad','2025-03-05');

๐Ÿ“‚ Step 7: Insert Sample Products

INSERT INTO products VALUES

(101,'Laptop','Electronics',65000),

(102,'Headphones','Electronics',2500),

(103,'Office Chair','Furniture',7000),

(104,'Keyboard','Electronics',1800),

(105,'Water Bottle','Home',600);

๐Ÿ“‚ Step 8: Insert Sample Orders

INSERT INTO orders VALUES

(1001,1,'2025-03-01','Delivered'),

(1002,2,'2025-03-03','Delivered'),

(1003,1,'2025-03-10','Delivered'),

(1004,3,'2025-03-15','Cancelled'),

(1005,4,'2025-03-20','Delivered');

๐Ÿ“‚ Step 9: Insert Sample Order Items

INSERT INTO order_items VALUES

(1,1001,101,1,65000),

(2,1001,102,2,2500),

(3,1002,103,1,7000),

(4,1003,104,1,1800),

(5,1004,105,3,600),

(6,1005,101,1,65000);

๐Ÿง  SQL Concepts You'll Practice

โœ” DDL Commands

โœ” DML Commands

โœ” Primary & Foreign Keys

โœ” Joins

โœ” Aggregate Functions

โœ” GROUP BY

โœ” HAVING

โœ” CASE WHEN

โœ” Subqueries

โœ” CTEs

โœ” Window Functions

โœ” Date Functions

๐Ÿ“Š Business KPIs You Can Build

๐Ÿ“ˆ Total Revenue

๐Ÿ“ˆ Total Orders

๐Ÿ“ˆ Total Customers

๐Ÿ“ˆ Average Order Value (AOV)

๐Ÿ“ˆ Revenue by Product Category

๐Ÿ“ˆ Monthly Sales Trend

๐Ÿ“ˆ Daily Sales Trend

๐Ÿ“ˆ Top 10 Selling Products

๐Ÿ“ˆ Top 10 Customers by Revenue

๐Ÿ“ˆ Revenue by City

๐Ÿ“ˆ Revenue by Gender

๐Ÿ“ˆ Customer Lifetime Value (CLV)

๐Ÿ“ˆ Repeat Purchase Rate

๐Ÿ“ˆ Customer Retention Rate

๐Ÿ“ˆ Customer Churn Rate

๐Ÿ“ˆ Average Products per Order

๐Ÿ“ˆ Order Cancellation Rate

๐Ÿ“ˆ Delivered vs Cancelled Orders

๐Ÿ“ˆ Best Selling Category

๐Ÿ“ˆ Worst Selling Category

๐Ÿ“ˆ Most Expensive Product Sold

๐Ÿ“ˆ Highest Revenue Month

๐Ÿ“ˆ Customer Acquisition by Month

๐Ÿ“ˆ New vs Returning Customers

๐Ÿ“ˆ Product-wise Revenue

๐Ÿ“ˆ Category-wise Revenue Contribution

๐ŸŽฏ Double Tap โค๏ธ For Part-2
  • โค 22
  • ๐Ÿ‘ 1
More from @sqlanalyst
  1. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  2. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  3. Oct 7, 2026SQL Interview Series โ€” Part 4 ๐Ÿ“Œ Question 4: Find the Highest Salary in Each Department Suโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Sep 29, 2026SQL Interview Series โ€” Part 2 ๐Ÿ“Œ Question 2: Find Duplicate Records Suppose you have an Emโ€ฆ
  6. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’