Skip to content

iamandy200/sql-ecommerce-analysis-task3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

sql-ecommerce-analysis-task3

End-to-end SQL data analysis project featuring schema creation, data modeling, aggregate queries, joins, subqueries, views, and performance optimization. Fully executed using SQLite with screenshots and documentation. πŸ“Œ Overview

This project demonstrates SQL skills for data analysis using an E-commerce dataset. The tasks include:

Creating tables

Inserting sample data

Running analytical SQL queries

Using joins, subqueries, GROUP BY, views, and indexes

Query optimization using EXPLAIN QUERY PLAN

Capturing results with screenshots

All queries were executed using SQLite (DB Browser for SQLite).

πŸ“ Project Structure Task3_SQL/ β”‚-- ecommerce_schema_and_queries.sql β”‚-- README.md └── screenshots/ β”œβ”€β”€ screenshot1_revenue_per_order.png β”œβ”€β”€ screenshot2_avg_revenue_per_user.png β”œβ”€β”€ screenshot3_view_output.png └── screenshot4_explain_query_plan.png

πŸ—‚οΈ Database Tables

The database contains the following tables:

users

products

orders

order_items

A view was also created:

vw_order_revenue

Indexes were added for performance optimization.

βš™οΈ How to Run This Project (SQLite)

  1. Install DB Browser for SQLite

Download: https://sqlitebrowser.org/dl/

  1. Create a Database

Open DB Browser β†’ New Database

Name it: ecommerce.db

Save it (do NOT add tables manually)

  1. Execute SQL File

Go to Execute SQL β†’ Click Open File β†’ Choose:

ecommerce_schema_and_queries.sql

Click Run All. This will automatically:

Create tables

Insert sample data

Create a view

Create indexes

Run queries

🧠 Key SQL Concepts Demonstrated βœ” SELECT, WHERE, ORDER BY βœ” GROUP BY and Aggregate Functions βœ” INNER JOIN and LEFT JOIN βœ” Subqueries and CTEs βœ” View Creation βœ” Handling NULL values (COALESCE) βœ” Query Optimization using Indexes βœ” EXPLAIN QUERY PLAN πŸ“ Main Queries Executed

  1. Revenue per Order

Calculates total revenue for each order.

  1. Average Revenue per User

Uses a subquery to calculate revenue per user based on completed orders.

  1. View: vw_order_revenue

Shows order-level revenue with order details.

  1. EXPLAIN QUERY PLAN

Used to verify that the index on order_items(product_id) is being used.

πŸ“Έ Screenshots Included 1️⃣ screenshot1_revenue_per_order.png

Shows output of:

SELECT oi.order_id, SUM(oi.quantity * oi.item_price) AS order_revenue FROM order_items oi GROUP BY oi.order_id ORDER BY order_revenue DESC;

2️⃣ screenshot2_avg_revenue_per_user.png

Shows output of the subquery/CTE-based user revenue calculation.

3️⃣ screenshot3_view_output.png

Output of:

SELECT * FROM vw_order_revenue;

4️⃣ screenshot4_explain_query_plan.png

Shows index usage: SEARCH oi USING INDEX ... SEARCH o USING INTEGER PRIMARY KEY ...

🎯 Conclusion

This project demonstrates end-to-end SQL data analysis skills:

Database design

Query writing

Complex aggregations

Query optimization

Practical execution in SQLite

All required screenshots and outputs are included.

πŸ™Œ Author

Anand Rathod BCA Graduate | Aspiring Data Analyst Skills: Python, SQL, Pandas, AWS, Power BI

About

End-to-end SQL data analysis project featuring schema creation, data modeling, aggregate queries, joins, subqueries, views, and performance optimization. Fully executed using SQLite with screenshots and documentation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors