SQL Repeat Send Rate by First-Transfer Cohort and Corridor
Last updated: November 29, 2026
Quick Overview
Using a transfers table, compute for each monthly cohort of first-time senders and each corridor the share of customers who completed a second transfer within 30 days of their first completed transfer.
Remitly
November 29, 20260
0
0 solved
Using a transfers table, compute for each monthly cohort of first-time senders and each corridor the share of customers who completed a second transfer within 30 days of their first completed transfer.
Repeat behavior is the heartbeat of a remittance business because most customers send on a regular schedule to family. The interviewer checks window functions, correct cohort definitions using only completed transfers, and the right handling of customers whose 30-day window has not closed yet.
What the Interviewer Expects
- Uses only completed transfers to define first and second sends
- Assigns cohort and corridor from the first transfer
- Uses window functions to find each customer's first and second transfers
- Excludes or flags cohorts whose 30-day window has not fully elapsed
- Handles ties on timestamp deterministically
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you change the query to count a repeat to any corridor versus the same corridor?
- How would you make this an incremental daily pipeline instead of a full recompute?
- Refunded transfers arrive as later status updates. How does that affect the metric?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
transfers(transfer_id, customer_id, send_country, receive_country, status, completed_at) with status values like COMPLETED, REFUNDED, CANCELLED. Corridor = `send_country || '-' || receive_coun...
Approach
Rank completed transfers per customer by completed_at, transfer_id. Take rank 1 as first and rank 2 as second. Cohort month and corridor come from rank 1. Only include customers whose first transfer...