Invite Reward Conversion per Inviter Within Seven Days
Last updated: November 29, 2026
Quick Overview
Given invite records and orders, compute for each inviter how many invitees they brought and how many of those placed a completed order within 7 days of the invite, counting only orders placed after the invite.
Temu
November 29, 20260
0
0 solved
Given invite records and orders, compute for each inviter how many invitees they brought and how many of those placed a completed order within 7 days of the invite, counting only orders placed after the invite.
Invite-a-friend rewards drive a lot of Temu sign-ups and are a target for abuse, so analysts need a trustworthy per-inviter conversion table to pay rewards and spot farming. This checks join conditions that respect time, aggregation without double counting, and keeping inviters whose invitees never bought.
What the Interviewer Expects
- Join orders to invites with a time condition, not just on user id
- Keep invitees with no orders via LEFT JOIN
- Take the first qualifying order per invitee before aggregating
- Ignore cancelled and refunded orders
- Explain how the output feeds fraud review
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you flag inviters whose invitees share devices or payment cards?
- What if an invitee was invited by two people? Who gets credit?
- How would you make this incremental in a daily pipeline?
- Which inviters would you send to manual review, and why?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
invites(inviter_id, invitee_id, invite_ts), orders(order_id, user_id, order_date, status). An invitee converts if they have a completed order on or after the invite date and within 7 days of it. O...
Approach
For each invite, find the earliest completed order on or after the invite date with a LEFT JOIN plus MIN, so invitees with no orders remain with NULL. Then aggregate per inviter with conditional sums....