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
Data Manipulation (SQL/Python)
Data Scientist
Zomato
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

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
Window functions
ROW_NUMBER
Cohorts
Conditional aggregation
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. 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 Problems
Sample 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....


Submit Your Answer
Markdown supported

Related Questions