Project 1: E-commerce SQL Analysis

Project Description

Created a small 30-row SQL sales dataset to demonstrate SQL skills in data cleaning, analysis, and insights.

SQL Table Creation

SQL Snippet

CREATE TABLE sales (
  order_id INT PRIMARY KEY,
  order_date DATE,
  customer_name VARCHAR(50),
  product VARCHAR(50),
  quantity INT,
  price FLOAT
);
      
SQL Output Screenshot

Inserting Sales Data

SQL Snippet

INSERT INTO sales (
  order_id, order_date, customer_name, product, quantity, price)
VALUES
  (1, '2025-6-1', 'Salim', 'Shoes', 2, 20),
  (2, '2025-3-3', 'Laudy', 'Shirt', 1, 15),
  (3, '2025-5-22', 'Reem', 'Shoes', 2, 20),
  (4, '2025-6-2', 'Siham', 'Pants', 1, 30.5);
      
Inserted Sales Data Screenshot

Which product sold the most?

SQL Snippet

SELECT product, SUM(quantity) AS total_quantity 
FROM sales 
GROUP BY product
ORDER BY total_quantity DESC 
LIMIT 1;
      
Most Sold Product Result

Total Revenue Per Product

SQL Snippet

SELECT product, SUM(quantity * price) AS total_revenue 
FROM sales 
GROUP BY product
ORDER BY total_revenue DESC;
      
Total Revenue per Product Result

Top Customer by Total Spending

SQL Snippet

SELECT customer_name, SUM(quantity * price) AS total_spent
FROM sales
GROUP BY customer_name 
ORDER BY total_spent DESC
LIMIT 1;
      
Top Customer Result

Which day had the highest sales?

SQL Snippet

SELECT order_date, SUM(quantity * price) AS daily_sales
FROM sales
GROUP BY order_date
ORDER BY daily_sales DESC
LIMIT 1;
      
Highest Day Sales

Which month had the highest sales?

SQL Snippet

SELECT DATE_FORMAT(order_date, '%Y-%m') AS month,
SUM(quantity * price) AS monthly_sales 
FROM sales
GROUP BY month
ORDER BY monthly_sales DESC
LIMIT 1;
      
Highest Month Sales