iPhone Trade-In Revenue by Store
Problem
**[Asked at Apple]**
Apple runs a trade-in program where customers exchange old iPhones for credit.
Each transaction references a `model_id`, and a separate table stores the
payout amount for each model.
Calculate the **total trade-in revenue per store**, ordered from highest to lowest.
Tables
Example rows — the live problem includes the full dataset.
transactions
| txn_id | model_id | store_id | txn_date |
|---|
payouts
| model_id | model_name | payout_amount |
|---|
Expected output
Your answer should return 3 rows with the columns store_id, total_revenue.
Starter code (SQL)
SELECT *
FROM transactions;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