Monthly revenue report
EasyP2Coding
Table orders:
| Column | Type |
|---|---|
| id | int (primary key) |
| amount | numeric(10,2) |
| created_at | timestamp (without time zone, already in the reporting time zone) |
Report revenue per calendar month, oldest month first. Months with no orders are not listed.
Output columns: month (text, formatted YYYY-MM) and revenue (sum of amount).
Schema
CREATE TABLE orders ( id int PRIMARY KEY, amount numeric(10,2) NOT NULL, created_at timestamp NOT NULL );
Example 1
- Input
- orders: (1, 10.00, 2024-01-15), (2, 5.50, 2024-01-20), (3, 7.00, 2024-02-01)
- Output
- 2024-01: 15.50, 2024-02: 7.00
Constraints
- PostgreSQL dialect.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
PostgreSQL
Run checks the 3 visible tests, Submit all 6. ⌘Enter runs, ⌘⇧Enter submits.