← Retention, funnels, cohorts

Return within 14 days by platform: Mar–May 2025, BY

Level: Middle100 XP

Instructions

A cohort is the users of one platform who signed up (users.signup_at) in one calendar month (cohort_month is the first day of the month). Take users from the country 'BY' who signed up from March 1, 2025 to May 31, 2025 inclusive. A user returned within 14 days if they have at least one event on one of the calendar days from the 1st through the 14th after signup: signup_at::date + 1 <= event_time::date <= signup_at::date + 14 (the signup day is day 0; events of that day are not counted). For each cohort, output cohort_month, platform, cohort_size (the number of users in the cohort, including those with no events), returned (the number of users who returned) and return_pct (returned / cohort_size × 100, rounded to 1 decimal place). Sort by cohort_month, then platform.

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