You're a product analyst at a B2B marketplace. The CRM team is preparing a customer win-back campaign and wants to know how many calendar days have passed since each active buyer's most recent successfully paid purchase as of July 1, 2026. Canceled, refunded, and incomplete orders, as well as records without a payment date, must not affect the metric. Exclude customers who have no qualifying orders.
Return these columns:
- customer_id — customer identifier, an integer
- customer_name — customer name
- last_paid_date — date of the most recent paid order in YYYY-MM-DD format
- recency_days — number of calendar days from last_paid_date to 2026-07-01, an integer
Rules:
- Include only orders with status paid and a non-NULL paid_at.
- Ignore orders after 2026-07-01.
- If a customer has multiple payments on their most recent payment date, return only one row for that customer.
- Sort by recency_days in ascending order, then by customer_id in ascending order.
- No rounding is required; the result must not contain any NULL values.
customer_idcustomer_namelast_paid_daterecency_daysShowing the first 3 rows of the sample — the full sample comes with Premium
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in