Follow the money to developers
HardAppleunion allrefundscommissionrank per groupsubscription cohorts· 160 XP (40 per question)
Mock interview. You're interviewing for a senior analyst job on an app store's developer relations team. The interviewer says: "Developers make money three ways: paid downloads, in-app purchases and subscriptions. We want one clean view of the money, then a few cuts of it."
The rules for this interview:
- A paid download is a first-time download (
is_redownloadfalse) of an app withprice > 0, worth the app'sprice. - Every row in
purchasesis a sale worthprice_usd. Ifrefunded_onhas a date, the money went back to the customer. - The store keeps a commission: 15% for developers in the small business program (
small_businesstrue), 30% for everyone else. The rest is the developer's proceeds.
Question 1: One view of every sale
"Put paid downloads and purchases into one list of sales, then show for each sale type: number of sales, gross amount, refunds and net (gross minus refunds)."
Expected output
sale_typeispaid downloadfor downloads and the purchase'sproduct_typeotherwise;refundsis 0 when there are none; sorted bynet, highest first
Example of the shape (made-up values):
| sale_type | sales | gross | refunds | net |
|---|---|---|---|---|
| paid download | 2000 | 8000.00 | 0 | 8000.00 |
Hints, the later questions and the answer come with Pro.
Question 1 of 4
Write your query here. Ctrl + Enter submits.