SQL practice: GROUP BY: One Answer Per Group
Chapter 10 · 13 questions · included in full access
Question 1 · easy
Solve it in your browserCount the orders per status.
Question 2 · easy
Solve it in your browserCount the customers per customer_type.
Question 3 · medium
Solve it in your browserFind the average salary per role, and show the headcount beside it.
Question 4 · medium
Solve it in your browserCount the branches per region.
Question 5 · medium
Solve it in your browserFind the total quantity sold per product_id.
Question 6 · medium
Solve it in your browserCount how many products fall under each thickness_mm value. What happens to the accessories?
Question 7 · medium
Solve it in your browserCount the orders per branch, counting only Delivered ones.
Question 8 · medium
Solve it in your browserFor each customer_type, show how many customers there are and the earliest signup_date.
Question 9 · medium
Solve it in your browserFor each branch, show total orders, delivered orders and cancelled orders as three separate columns.
Question 10 · medium
Solve it in your browserCount how many employees report to each manager_id.
Question 11 · medium
Solve it in your browserFind the total revenue per product_id from order_items (quantity × unit_price).
Question 12 · hard
Solve it in your browserWhy does SELECT branch_id, order_date, COUNT(*) FROM orders GROUP BY branch_id; fail? Fix it by aggregating order_date with MAX() as latest_order so each branch has one summary row.
Question 13 · hard
Solve it in your browserFix this query so it correctly counts the number of products in each category.
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing