Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Invite Behavior and User Retention

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

Your question is Invite Behavior and User Retention. Start with the requirements and the three 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

You are given the task of measuring whether users who invite teammates in Asana are more likely to retain. Write a SQL query that groups users by whether they sent at least one teammate invite within 7 days of signup, then calculates each group’s 30-day retention rate. Treat a user as retained if they have at least one activity event on or after day 30 and on or before day 60 after signup. Return the invite cohort, total users, retained users, and retention rate, ordered by the invite cohort.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
signup_dateDATEDate the user signed up for Asana
plan_tierVARCHAR(20)Plan tier at signup
country_codeVARCHAR(2)Two-letter country code
invites
ColumnTypeDescription
invite_idPKINTUnique invite identifier
inviter_user_idINTUser who sent the teammate invite
invitee_emailVARCHAR(255)Email address invited to join
sent_atDATEDate the invite was sent
activity_events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idINTUser who generated the activity event
event_dateDATEDate of the activity event
event_nameVARCHAR(50)Type of activity event in Asana
Tablesusersinvitesactivity_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results