Interactive lab / SQL
Mzansi Retail Analytics
Run real SQLite queries against a deterministic, synthetic South African retail database. No real customer information is used. All processing happens in your browser.
Database schema
Customers → Orders ← Stores
Orders → Order items ← Products
Orders → Payments
Loading database…
Query workspace
Loading SQL engine…
Result visualisation
Run an aggregate query to plot a numeric column.
SQL challenges
Beginner — count customers by province
Use COUNT and GROUP BY on customers.
SELECT province, COUNT(*) FROM customers GROUP BY province;
Intermediate — revenue by product category
Join products and order_items and aggregate quantity times unit_price.
SELECT p.category, SUM(i.quantity*i.unit_price) AS revenue FROM products p JOIN order_items i ON p.id=i.product_id GROUP BY p.category;
Advanced — rank customers by spending
Aggregate spending in a CTE, then apply DENSE_RANK over descending totals. See the customer ranking example.