Share of New Customers Acquired Through a Promo Code
Last updated: November 29, 2026
Quick Overview
Given an orders table with customer, timestamp, status and an optional promo code, report for each month the number of new customers (by first delivered order) and the percentage whose first order used a promo.
Zomato
November 29, 20260
0
0 solved
Given an orders table with customer, timestamp, status and an optional promo code, report for each month the number of new customers (by first delivered order) and the percentage whose first order used a promo.
Zomato's growth team leans on welcome coupons, and finance wants to know how dependent acquisition is on discounts. The screen checks a clean first-event pattern with window functions and careful definition of 'new customer'.
What the Interviewer Expects
- Define a new customer by the first delivered order, not the first attempt
- Use ROW_NUMBER with a deterministic tie-breaker
- Group by the month of the first order
- Compute the percentage with float division
- Explain how cancelled promo orders are treated
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 compare 90-day retention of promo-acquired versus organic customers?
- How would you exclude accounts that look like coupon abusers sharing one device?
- What if a customer's first order was placed in a different city from later ones?
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
orders(order_id, customer_id, created_at, status, promo_code), with promo_code NULL when none. I will count a customer as acquired on their first delivered order, because a cancelled order is not ...
Approach
Rank each customer's delivered orders by time, keep rank 1, then group those first orders by month and compute the share with a non-null promo code. One pass, no self join....