Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Retention Rate SQL Query

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Retention Rate SQL Query. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Remitly wants to measure how consistently newly registered customers complete transfers after signup. Write a PostgreSQL query to calculate monthly retention for the January 2024 signup cohort.

Requirements

  1. Treat users who signed up from 2024-01-01 through 2024-01-31 as the cohort.
  2. Calculate retention for months 0, 1, and 2, where month 0 is January 2024.
  3. Count each user at most once per month, even if they complete multiple transfers.
  4. Return the cohort size, retained users, and retention rate, using all cohort users as the denominator. Order by month number.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Remitly customer identifier
signup_dateDATEDate the customer registered
country_codeVARCHAR(2)Customer registration country
remitly_transfers
ColumnTypeDescription
transfer_idPKINTUnique transfer identifier
user_idINTCustomer who initiated the transfer
completed_atTIMESTAMPTransfer completion timestamp
channelVARCHAR(20)Transfer initiation channel
Tablesusersremitly_transfers
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results