Easy Aggregation Free

SQL interview question: Count Orders by Status

Order Status Distribution

Operations needs a breakdown of order statuses to identify bottlenecks.

Count how many orders are in each status.

Return status and order_count. Order by order_count descending.

Skills: simple GROUP BY with COUNT

Tables

orders 15 rows
  • order_id integer PK
  • customer_id integer → customers
  • order_date text
  • total_amount real
  • status text
order_idcustomer_idorder_datetotal_amountstatus
11012024-01-20249.99delivered
21012024-03-151999.99delivered
41012024-09-0579.99delivered
About the e-commerce sample database

Practice on your iPhone

Query Dojo for iPhone has 85 interview questions, timed mock interviews and a tile builder, so you can write queries without a keyboard.

Get the app

Keep going