← Retention, funnels, cohorts

Classic vs rolling day-14 retention: Mar–May 2025, all

Level: Senior200 XP

Instructions

A cohort is the users who signed up (users.signup_at) in one calendar month (cohort_month is the first day of the month). Take all users who signed up from March 1, 2025 to May 31, 2025 inclusive. Classic day-14 retention: the user has an event on exactly the 14th calendar day after signup (event_time::date = signup_at::date + 14, the signup day is day 0). Rolling day-14 retention: the user has at least one event on the 14th day or later (event_time::date >= signup_at::date + 14); the data has events through June 30, 2025 inclusive. For each cohort, output cohort_month, cohort_size (the number of users in the cohort, including those with no events), day_n_users and rolling_users (the number of users retained in the classic and in the rolling sense) and day_n_pct, rolling_pct (these numbers as a percentage of cohort_size, × 100, rounded to 1 decimal place). Sort by cohort_month.

Hints

Each next one is more detailed and costs more

Log in to open hints

Query

Result

Click Run to see the query result, or Check to submit your solution.

Dataset schema

events.user_id (0…N) ↔ users.id (1…1)purchases.user_id (0…N) ↔ users.id (1…1)eventsPKidintegerFKuser_idintegerpurchasesPKidintegerFKuser_idintegerusersPKidinteger
Exactly oneZero or oneZero or more
Table relationships
  • N:1Many-to-oneevents.user_id → users.id
  • N:1Many-to-onepurchases.user_id → users.id

Table data

PostgreSQL

Select a table in the diagram or list to view its rows.

Dataset schema