Totals by Month
day is a date written as text, like 2026-03-14. Return one row per month that has orders: month as the first 7 characters of the date (2026-03) and total, the sum of amount in that month. Earliest month first.
Example 1
orders
| id | day | amount |
|---|---|---|
| 1 | 2026-01-05 | 100 |
| 2 | 2026-01-20 | 50 |
| 3 | 2026-02-01 | 70 |
| 4 | 2025-12-31 | 5 |
returns
| month | total |
|---|---|
| 2025-12 | 5 |
| 2026-01 | 150 |
| 2026-02 | 70 |
Constraints
- Up to 16 orders
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Above the AverageMedium
- Best Paid in Each DepartmentMedium
- Bought but Never SoldMedium
- Change From the Day BeforeMedium
- First OrderMedium
- Latest PriceMedium
- More Than the ManagerMedium
- Open PositionsMedium