Eligible Trade-In Payouts
Problem
Table: `TradeIn`
```text
+----------+-----------+-----------+--------+--------+
| Column | Type | | | |
+----------+-----------+-----------+--------+--------+
| trade_id | int | | | |
| base_val | float | | | |
| payout | float | | | |
| east | float | | | |
| north | float | | | |
+----------+-----------+-----------+--------+--------+
trade_id is the primary key. `base_val` is the appraised base value, `payout` is the offered payout, and (`east`, `north`) is the grid location of the drop-off depot (never NULL).
```
Report the sum of `payout` over all trade-ins that satisfy **both**:
- their `base_val` equals the `base_val` of at least one other trade-in, **and**
- their depot location (`east`, `north`) is unique — no other trade-in shares the same (east, north) pair.
Round the total to **two decimal places** and label the column `payout`.
Tables
Example rows — the live problem includes the full dataset.
| trade_id | base_val | payout | east | north |
|---|---|---|---|---|
| 1 | 10 | 5 | 10 | 10 |
| 2 | 20 | 20 | 20 | 20 |
| 3 | 10 | 30 | 20 | 20 |
Expected output
Your answer should return 1 row with the columns payout.
Starter code (SQL)
SELECT *
FROM TradeIn;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock