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_idcustomer_namelast_paid_daterecency_days
4Delta Foods2026-06-301
8Harbor Tools2026-06-301
1Acorn Labs2026-06-283
PostgreSQLv16
Entre para enviar

O resultado da sua consulta aparecerá aqui

Focus radio
Paused · SomaFM · Fluid