task Revenue & order value · medium
Monthly revenue after refunds
For delivered orders, return month (YYYY-MM of order_date) and net_revenue: line revenue (quantity × unit_price) minus refunds for those orders.
what to return
- Columns
monthnet_revenuein this order- Rows
- 4 rows · any order
- Watch for
- Orders without refunds subtract 0.
- Round net_revenue to 2 decimals.
- Months with no delivered orders aren't listed.
- Skill
- Combine line totals and refunds without double counting. Refresher: Revenue & payment reconciliation →
expected result
Your query should return exactly these columns and values. Run it and compare.
expected result4 rows · any order
| month | net_revenue |
|---|---|
| 2025-01 | 331 |
| 2025-02 | 448 |
| 2025-03 | 864.5 |
first 3 of 4 rows
data you can query
Sample rows from each table. Each column shows its type underneath; → marks a link to another table.
sales_orders5 columns · 33 rows
| idinteger · key | shopper_idinteger → shoppers | order_datetext | statustext | delivered_datetext |
|---|---|---|---|---|
| 101 | 1 | 2025-01-04 | delivered | 2025-01-08 |
| 102 | 2 | 2025-01-06 | delivered | 2025-01-07 |
| 103 | 1 | 2025-01-15 | delivered | 2025-01-20 |
| 104 | 3 | 2025-01-18 | cancelled | NULL |
| 105 | 4 | 2025-01-22 | delivered | 2025-01-31 |
showing 5 of 33 rows
order_lines4 columns · 48 rows
| order_idinteger → sales_orders | item_idinteger → catalog_items | quantityinteger | unit_pricereal |
|---|---|---|---|
| 101 | 1 | 1 | 39 |
| 101 | 3 | 2 | 19.5 |
| 102 | 4 | 1 | 59 |
| 103 | 5 | 1 | 45 |
| 103 | 10 | 3 | 12 |
showing 5 of 48 rows
order_refunds4 columns · 6 rows
| idinteger · key | order_idinteger | refunded_attext | amountreal |
|---|---|---|---|
| 1 | 103 | 2025-01-25 | 15 |
| 2 | 106 | 2025-02-06 | 74 |
| 3 | 111 | 2025-02-25 | 59 |
| 4 | 111 | 2025-02-26 | 45 |
| 5 | 122 | 2025-03-20 | 10 |
showing 5 of 6 rows
solution.sql
Hints and the answer are always available. Using them counts the question as solved with help.