Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Compare Asana Retention Cohorts by Channel

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

Your question is Compare Asana Retention Cohorts by Channel. 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

Asana’s growth team wants to compare early retention for users acquired through ChatGPT versus all other acquisition channels. Write a PostgreSQL query that builds weekly signup cohorts and reports week 0 through week 4 retention for each cohort and acquisition segment.

Requirements

  1. Define each user’s cohort by the week of signup from users.signup_date.
  2. Split users into two acquisition segments:
    • ChatGPT when acquisition_channel = 'ChatGPT'
    • Other for every other non-null channel Exclude users with a null acquisition channel.
  3. Count a user as retained in week n if they had at least one activity in Asana during the nth week after signup, using activity_date from user_activity.
  4. Return one row per cohort_week, acquisition_segment, and week_number for weeks 0-4.
  5. Include cohort_size, retained_users, and retention_rate rounded to 4 decimal places.
  6. Order the final output by cohort_week, acquisition_segment, and week_number.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Asana user identifier
signup_dateDATEDate the user signed up
acquisition_channelVARCHAR(50)Marketing or referral source that acquired the user
workspace_idINTFirst Asana workspace the user joined
user_activity
ColumnTypeDescription
activity_idPKINTUnique activity event identifier
user_idINTUser who performed the activity
activity_dateDATEDate of the Asana activity
activity_typeVARCHAR(50)Type of activity performed
Tablesusersuser_activity
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results