Revenue per user, before and after trimming
Zalora tested a personalised recommendations rail. Revenue per user is a heavy-tailed metric: a single stylist buying a season's stock can move a variant's mean on its own, and which arm that buyer happens to land in is luck, not treatment effect. The usual defence is to trim the extreme tail before comparing.
From user_revenue (2,000 users), return each variant with:
- mean_revenue — the plain average, rounded to 4 decimal places
- trimmed_mean — the average over only those users at or below that variant's own 99th percentile of revenue, rounded to 4 decimal places
Order by variant.
Schema
| user_id | INT |
| variant | TEXT |
| revenue | NUMERIC(10,2) |
Basic
The example input, expected output, and walkthrough for this question unlock with a Basic plan.
Basic
This is a Basic question
Premium practice questions unlock with a Basic plan. The full solution, expected output, and grading are available to Basic members.