sql

Week-one retention by signup cohort

SQL & Data Modeling · Funnels & Sessions · medium · Original Uplift question · PostgreSQL · 20 min

Group users by Monday-starting signup week. A user is retained in week one if they have at least one learning event from 7 through 13 days after their signup date, inclusive. Return cohort_week, cohort_size, retained_users, and retention_rate rounded to two decimals.

Fixture

learners

user_id, signup_date

learning_events

user_id, event_date

CREATE TABLE learners (user_id INT PRIMARY KEY, signup_date DATE);
CREATE TABLE learning_events (user_id INT, event_date DATE);
INSERT INTO learners VALUES (1,'2025-01-06'),(2,'2025-01-07'),(3,'2025-01-13'),(4,'2025-01-14');
INSERT INTO learning_events VALUES
(1,'2025-01-13'),(1,'2025-01-20'),(2,'2025-01-12'),(2,'2025-01-20'),
(3,'2025-01-19'),(3,'2025-01-26'),(4,'2025-01-21');

Evaluation criteria

  • Uses signup week rather than event week as the cohort
  • Applies the inclusive day-7-through-day-13 window per user
  • Counts retained users once despite multiple events

Detailed grading feedback appears after you submit.

Source

Original Uplift question based on a common interview pattern.

Your answer

You get one graded attempt here without an account. Create a free account for unlimited attempts, saved progress and community write-ups.

Answers stay hidden until you ask. Reveal the full model write-up when you are ready to compare.

Community

How other people solved this

There is rarely one right query or one right framing. Read how others approached it, and share your own once you have submitted an answer.

Reading is open to everyone. Sign in to share your approach or mark a write-up as helpful.

Loading write-ups…