← SQL Operations Cases
Lesson 2 of 4
Account for partial refunds
Aggregate multiple refunds before calculating net revenue.
Do the work
- An order may have more than one refund row.
- Sum refunds by order_id before joining.
- Net revenue equals amount minus total refund.
See the method
Order 1 refunds are 20 and 10.
Read every demonstration step
- Order 1 refunds are 20 and 10.
- Preaggregate to 30 before joining to its 120-dollar sale.
- Net amount is 90, not 210 from a duplicated sale.
Practice independently
Take it further
Inspect orphan refund records separately instead of forcing a match.