This project demonstrates the use of MySQL for solving real-world e-commerce business problems. The analysis focuses on customer purchasing behavior, revenue trends, product performance, customer engagement, and session-to-purchase behavior.
The project uses a relational database containing information about users, products, orders, order items, and user sessions.
The database consists of five tables:
- users – Customer information, country, join date, and membership tier
- products – Product details, categories, and prices
- orders – Customer orders, order dates, amounts, and order status
- order_items – Individual products and quantities within each order
- user_sessions – User browsing sessions, session duration, and page views
The analysis answers the following business questions:
-
Month-over-Month Revenue Growth Calculate monthly revenue from completed orders and analyze MoM revenue growth.
-
First-Order Conversion Bottleneck Identify how many users placed a completed order within 10 days of joining, grouped by country.
-
Customer Lifetime Value (CLV) Tiering Rank customers within each country based on their total spending.
-
Sticky Categories Identify users who purchased products from multiple categories within the same calendar month.
-
Top Products per Category Identify the top two revenue-generating products within each product category.
-
User Session Engagement Metrics Compare average session duration and average page views across membership tiers.
-
Purchase Interval Analysis Calculate the number of days between consecutive orders for each user.
-
Session-to-Purchase Conversion Attribution Identify the most recent user session before each completed purchase.
- SQL Joins
- Aggregate Functions
- GROUP BY and HAVING
- Subqueries
- Window Functions
LAG()ROW_NUMBER()DENSE_RANK()PARTITION BY- Date and Time Functions
TIMESTAMPDIFF()DATEDIFF()COALESCE()- Customer and Revenue Analytics
ecommerce-sql-business-case-study/
├── README.md
├── schema.sql
├── sample_data.sql
├── questions.md
└── solutions.sql
Contains the SQL statements used to create the database tables.
Contains sample e-commerce data used for the analysis.
Contains the business problems addressed in the project.
Contains the SQL queries used to solve each business problem.
- Create a MySQL database.
- Run
schema.sqlto create the required tables. - Run
sample_data.sqlto insert the sample data. - Review the business problems in
questions.md. - Run the queries in
solutions.sqlto perform the analysis.
This project demonstrates how SQL can be used to transform transactional and behavioral data into meaningful business insights. The analysis covers important areas such as revenue growth, customer conversion, customer lifetime value, product performance, purchasing patterns, and user engagement.
Emmanuel Thomas
Aspiring Data Analyst | SQL | Python | Pandas | Excel | Power BI | Snowflake