Home/Learn SQL/E-commerce Database
Browse SQL Topics
Intermediate Level6 Tables

E-commerce Database SQL Tutorial

E-commerce system with products, customers, orders and inventory. Practice sales analysis, revenue queries and customer insight reports.

🎯 What you'll practice: Sales analysis, Inventory management, Customer insights, Revenue tracking using real-world database scenarios.

📊 Database Tables

products

Core ecommerce data table

customers

Core ecommerce data table

orders

Core ecommerce data table

order_items

Core ecommerce data table

categories

Core ecommerce data table

suppliers

Core ecommerce data table

🔍 Common Query Patterns

Top Selling Products

Find products with highest sales volume

SELECT p.product_name,
SUM(oi.quantity) as total_sold
FROM products p
JOIN order_items oi ON p.product_id = oi.product_id
GROUP BY p.product_name
ORDER BY total_sold DESC
LIMIT 5;
Try Now →

Monthly Revenue Analysis

Calculate revenue by month

SELECT DATE_FORMAT(o.order_date, '%Y-%m') as month,
SUM(oi.quantity * oi.unit_price) as revenue
FROM orders o
JOIN order_items oi ON o.order_id = oi.order_id
GROUP BY month
ORDER BY month DESC;
Try Now →

Ready to practice the concepts?

Continue in SQL Topics, where every exercise is owned by a clear SQL concept and an independently verified dataset contract.