SLSkillLoop
SQL practice

SQL GROUP BY Practice

GROUP BY helps you summarize rows into useful totals, counts, and averages. Practice common aggregate query patterns with short SQL examples.

Example practice questions

Try these samples, then continue into the SQL Practice Labfor guided browser-based practice.

1

Count orders by status.

Answer: SELECT status, COUNT(*) FROM orders GROUP BY status;

2

Find total sales by customer_id.

Answer: SELECT customer_id, SUM(total) FROM orders GROUP BY customer_id;

3

Find average price by category.

Answer: SELECT category, AVG(price) FROM products GROUP BY category;

4

Count users by country.

Answer: SELECT country, COUNT(*) FROM users GROUP BY country;

5

Filter grouped statuses with more than 10 orders.

Answer: SELECT status, COUNT(*) FROM orders GROUP BY status HAVING COUNT(*) > 10;