SQL Practice Logo

SQLPractice Online

Multiple Table Joins: Real-World

Module: Joins & Relationships

Every complex report joins multiple tables. Order details need customers, products, categories, shipping info. Employee reports need departments, locations, managers, projects.

E-commerce Order Fulfillment Dashboard

Operations team needs comprehensive order dashboard showing customer info, product details, inventory status, and shipping information for order processing and fulfillment.

Multi-table join connecting orders, customers, products, inventory, and shipping tables

SELECT

o.order_id,

c.customer_name,

c.email,

p.product_name,

oi.quantity as ordered_qty,

inv.stock_quantity,

CASE

WHEN inv.stock_quantity >= oi.quantity THEN 'In Stock'

WHEN inv.stock_quantity > 0 THEN 'Partial Stock'

ELSE 'Out of Stock'

END as stock_status,

s.shipping_method,

s.tracking_number

FROM orders o

INNER JOIN customers c ON o.customer_id = c.customer_id

INNER JOIN order_items oi ON o.order_id = oi.order_id

INNER JOIN products p ON oi.product_id = p.product_id

LEFT JOIN inventory inv ON p.product_id = inv.product_id

LEFT JOIN shipping s ON o.order_id = s.order_id

WHERE o.status = 'pending'

ORDER BY o.order_date;

Operations can quickly identify orders ready to ship, partial stock situations, and shipping status. Reduces fulfillment time and improves customer satisfaction.

All

Sales Performance Analytics

Sales team needs detailed performance reports showing salesperson results, customer segments, product categories, and regional performance for commission calculations and territory planning.

Complex join across sales, employees, customers, products, categories, and regions

SELECT

e.employee_name as salesperson,

r.region_name,

cat.category_name,

COUNT(DISTINCT o.order_id) as orders_count,

COUNT(DISTINCT c.customer_id) as unique_customers,

SUM(oi.quantity * oi.unit_price) as total_revenue,

AVG(oi.quantity * oi.unit_price) as avg_order_value

FROM employees e