How do you calculate day-one retention from repeated events?
Question
Each user has one signup row. Group signups by UTC date. The sample covers the full next day for both cohorts. Return signups and users active on the next UTC date. Count a returning user once, even with repeated events. Keep cohorts with zero returns. Sort by signup date.
signups
| user_id | signup_date |
|---|---|
| 1 | 2026-12-01 |
| 2 | 2026-12-01 |
| 3 | 2026-12-01 |
| 4 | 2026-12-02 |
activity
| user_id | event_date |
|---|---|
| 1 | 2026-12-02 |
| 1 | 2026-12-02 |
| 2 | 2026-12-02 |
| 3 | 2026-12-03 |
| 4 | 2026-12-02 |
Show hints (2)
- "ONE ROW PER SIGNUP"
Decide whether each user returned before counting users in a cohort.
- "CHECK THE NEXT DATE"
Use a matching activity date one calendar day after each signup date.
Show checked explanation
Start from the signup rows. Use EXISTS to check for activity on the next date, then sum the per-user return flag by signup date.
SELECT s.signup_date, COUNT(*) AS signups, SUM(CASE WHEN EXISTS ( SELECT 1 FROM activity AS a WHERE a.user_id = s.user_id AND a.event_date = date(s.signup_date, '+1 day') ) THEN 1 ELSE 0 END) AS returned_users FROM signups AS s GROUP BY s.signup_date ORDER BY s.signup_date;
signup_date | signups | returned_users 2026-12-01 | 3 | 2 2026-12-02 | 1 | 0
Ran the query on SQLite 3.49 with the sample rows and edge cases.
Walkthrough
Users 1 and 2 returned on December 2. User 1's two events still produce one true flag. User 3 returned a day later than the question asks. User 4 has only a signup-day event. December 2 stays in the output with zero returns because the query starts from signups.
Common mistakes
- Counting activity rows and treating both events for user 1 as two returning users.
- Counting any activity after signup, which would include user 3.
- Using an inner join and dropping the cohort with zero returns.
Follow-up questions
- "How would you convert these counts to day-one retention rates?" Divide returned users by signups using decimal division. The two sample cohorts yield 2/3 and 0, respectively.
- "What if events arrive as timestamps in multiple time zones?" Choose the reporting time zone, convert each timestamp to its date in that zone, and then apply the next-date test.
What a strong answer covers
State the unit of counting, define the day boundary, and keep zero-return cohorts.
Open in interactive practice deck →