StepsEasy
SQL GROUP BY - Example
Run
Reset
Destroy & Close
← Back to lesson
Code Editor
sql
-- Count orders per customer SELECT customer_id, COUNT(*) AS total_orders, SUM(amount) AS total_spent, AVG(amount) AS avg_order FROM orders GROUP BY customer_id HAVING total_spent > 1000 ORDER BY total_spent DESC;
Result
Click "Run" to execute the code...
Loading runtime...
Ready
SQL | In-Browser Execution