Loading problem...
A retail intelligence team needs a compact weekly report that summarizes sold units by product category.
Table: orders
Table: items
Task: For every category in items, compute total ordered quantity for each weekday bucket:
Output requirements:
Supported submission environments:
orders:
| order_id | customer_id | order_date | item_id | quantity |
|----------|-------------|------------|---------|----------|
| 1 | 101 | 2026-01-05 | A1 | 8 |
| 2 | 101 | 2026-01-12 | A2 | 6 |
| 3 | 202 | 2026-01-06 | A1 | 5 |
| 4 | 303 | 2026-01-07 | P1 | 4 |
| 5 | 404 | 2026-01-08 | P2 | 3 |
| 6 | 505 | 2026-01-09 | G1 | 7 |
| 7 | 606 | 2026-01-09 | A1 | 2 |
| 8 | 707 | 2026-01-11 | P2 | 5 |
items:
| item_id | item_name | item_category |
|---------|----------------------|---------------|
| A1 | Algorithms Handbook | Book |
| A2 | Query Playbook | Book |
| P1 | Alpha Phone | Phone |
| P2 | Beta Phone | Phone |
| G1 | Smart Glasses | Glasses |
| T1 | Cotton Tee | T-Shirt |[
{"category":"Book","Monday":14,"Tuesday":5,"Wednesday":0,"Thursday":0,"Friday":2,"Saturday":0,"Sunday":0},
{"category":"Glasses","Monday":0,"Tuesday":0,"Wednesday":0,"Thursday":0,"Friday":7,"Saturday":0,"Sunday":0},
{"category":"Phone","Monday":0,"Tuesday":0,"Wednesday":4,"Thursday":3,"Friday":0,"Saturday":0,"Sunday":5},
{"category":"T-Shirt","Monday":0,"Tuesday":0,"Wednesday":0,"Thursday":0,"Friday":0,"Saturday":0,"Sunday":0}
]Categories are grouped using items.item_category. Every ordered row contributes its quantity to exactly one weekday bucket. T-Shirt appears with all zeros because it has no matching orders.
orders:
| order_id | customer_id | order_date | item_id | quantity |
|----------|-------------|------------|---------|----------|
| 100 | 1 | 2026-02-02 | I10 | 3 |
| 100 | 1 | 2026-02-02 | I11 | 2 |
| 101 | 2 | 2026-02-03 | I12 | 4 |
| 102 | 2 | 2026-02-09 | I12 | 1 |
items:
| item_id | item_name | item_category |
|---------|----------------|---------------|
| I10 | Fast Charger | Accessories |
| I11 | USB-C Cable | Accessories |
| I12 | Wireless Mouse | Peripherals |[
{"category":"Accessories","Monday":5,"Tuesday":0,"Wednesday":0,"Thursday":0,"Friday":0,"Saturday":0,"Sunday":0},
{"category":"Peripherals","Monday":1,"Tuesday":4,"Wednesday":0,"Thursday":0,"Friday":0,"Saturday":0,"Sunday":0}
]The same order_id can include multiple item rows. Totals are still aggregated by category and weekday.
orders:
| order_id | customer_id | order_date | item_id | quantity |
|----------|-------------|------------|---------|----------|
items:
| item_id | item_name | item_category |
|---------|-----------|---------------|
| B1 | Novel | Books |
| B2 | Comics | Books |
| S1 | Pen | Stationery |[
{"category":"Books","Monday":0,"Tuesday":0,"Wednesday":0,"Thursday":0,"Friday":0,"Saturday":0,"Sunday":0},
{"category":"Stationery","Monday":0,"Tuesday":0,"Wednesday":0,"Thursday":0,"Friday":0,"Saturday":0,"Sunday":0}
]When there are no orders, every category from items must still appear with zeros for all weekday columns.
Constraints