CODE WORKSPACE

Interview top buyers with ties

Return buyer_id, paid_revenue, and buyer_rank for buyers whose paid-revenue rank is at most 3.

Start by naming the output grain, then build CTEs that can be inspected one at a time.

Sample input

paid buyer revenueRevenue is summed per buyer before ranking.
buyer_idpaid_orders
2540 + 110
6640
3120 + 95
180

Expected output

Expected outputTop three revenue ranks. Ties would share rank because this lab uses RANK.
buyer_idpaid_revenuebuyer_rank
26501
66402
32153

Constraints

State the output contract first, use readable CTE layers, return the exact columns requested by the prompt, and use deterministic ordering.

Expected skills

Interview clarification, SQL structure, edge-case handling, and final-answer narration.

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.