Intermediate Level6 Tables
E-commerce Database SQL Tutorial
Online retail system with products, customers, orders, and inventory
🎯 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;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;🚀 Ready to Practice?
Start practicing SQL queries with the e-commerce database database. All tables are loaded and ready to use!