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.
Exemplo de resposta esperada
É assim que se parece uma resposta correta: ela tem seu próprio número de linhas e não precisa coincidir com as tabelas do esquema. Sua resposta precisa retornar os mesmos nomes de colunas do exemplo: use AS para renomeá-las se for preciso.
| 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 |
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
Entrar