Orders per month
Mediumrow order matters
Show each month (as 2025-01) and the number of orders, in month order.
Tables: customers(customer_id, name, city, country, joined) · products(product_id, name, category, price) · orders(order_id, customer_id, order_date, status) · order_items(order_id, product_id, quantity, unit_price)
Your query✔ Solved
Show the expected result
| month | orders |
|---|---|
| 2025-01 | 2 |
| 2025-02 | 3 |
| 2025-03 | 8 |
| 2025-04 | 5 |
| 2025-05 | 5 |
| 2025-06 | 2 |
| 2025-07 | 5 |
| 2025-08 | 6 |
| 2025-09 | 2 |
| 2025-10 | 6 |
| 2025-11 | 3 |
| 2025-12 | 4 |
12 rows
Show a solution
SELECT strftime('%Y-%m', order_date) AS month, COUNT(*) AS orders FROM orders GROUP BY month ORDER BY month;
SQL used
New to SQL? The free SQL course teaches everything these problems use, with a self-checking exercise in every lesson.