Which Customers Need a Win-Back Campaign?
Which Customers Need a Win-Back Campaign?
You are a product analyst at a B2B marketplace. The CRM team is preparing a win-back campaign and needs to know how many days have passed since each active buyer's most recent genuinely paid purchase as of July 1, 2026. Cancelled, refunded, unfinished orders and records without a payment timestamp must not affect the metric. Customers with no qualifying order must be excluded.
Return columns:
- customer_id — customer identifier, integer
- customer_name — customer name
- last_paid_date — date of the latest paid order in YYYY-MM-DD format
- recency_days — calendar days from last_paid_date to 2026-07-01, integer
Rules:
- Use only orders with status paid and a non-NULL paid_at.
- Ignore orders after 2026-07-01.
- If a customer has several payments on the same latest date, return one customer row.
- Sort by recency_days ascending, then customer_id ascending.
- No rounding is needed; the result must contain no NULL values.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables. Your answer must use the same column names as this sample — alias them with AS if needed.
| customer_id | customer_name | last_paid_date | recency_days |
|---|---|---|---|
| 4 | Delta Foods | 2026-06-30 | 1 |
| 8 | Harbor Tools | 2026-06-30 | 1 |
| 1 | Acorn Labs | 2026-06-28 | 3 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in