Your sales manager needs the weekly performance summary before the Monday stand-up. She wants: total orders by region, revenue by product category, average order value, the top 3 reps by revenue, and only categories that exceeded ยฃ50,000 this quarter. Build each query and the report fills automatically.
SELECT r.name, COUNT(o.id) FROM orders o JOIN regions r ON o.region_id=r.id GROUP BY r.name;SELECT p.category, SUM(o.amount_gbp) FROM orders o JOIN products p ON o.product_id=p.id GROUP BY p.category;SELECT AVG(amount_gbp) FROM orders;SELECT r.full_name, SUM(o.amount_gbp) FROM orders o JOIN reps r ON o.rep_id=r.id GROUP BY r.full_name ORDER BY 2 DESC LIMIT 3;SELECT p.category, SUM(o.amount_gbp) as revenue FROM orders o JOIN products p ON o.product_id=p.id GROUP BY p.category HAVING revenue > 50000;You can type shortened versions โ the terminal recognises the key clauses. Each successful query populates the Report Preview window and checks off a goal.