Skip to content

Month-one retention by sign-up cohort

The task

Product wants month-one retention for each sign-up cohort.

A user's cohort is the calendar month they signed up (users.signed_up_at). A user is retained if they fired any event in the next calendar month: someone who signed up in January is retained if they did anything in February.

Return cohort_month (the first day of the cohort's month), cohort_size (users who signed up that month), retained_users and retention_pct (retained users as a percentage of the cohort, rounded to 1 decimal place). Sort by cohort_month.

Expected output

cohort_monthcohort_sizeretained_usersretention_pct
  • Sorted by cohort_month ascending.
  • Numbers rounded to 1 decimal place.
  • Checked on the sample and on 2 hidden datasets. How grading works

Tables Mobile shopping app · click a name to insert it

users360 rows in the sample

One row per user. Key: user_id.

intUnique id.
timestampSign-up time (UTC).
textTwo-letter country code.
textios, android or web.
textorganic, paid, referral or partner. NULL when unknown.
events7,616 rows in the sample

One row per tracked event. Key: event_id.

bigintUnique id.
intWho fired it.
textapp_open, search, view_item, add_to_cart, begin_checkout, purchase or share.
timestampWhen (UTC).
textSession the event belongs to. NULL for a few events sent from the background.
numeric(10,2)Order value for purchase events, NULL otherwise.
experiment_assignments349 rows in the sample

Which variant each user saw in each experiment. Key: user_id, experiment.

intThe user.
textnew_onboarding or one_tap_checkout.
textcontrol or treatment.
timestampWhen the user was assigned (UTC).

Related questions

Loading the editor and PostgreSQL