APPENDIX · P8 · METRICS · FOR THE SLIDE20
← Back to the slide20
P8. Retention: retention()
SELECT sum(r[1]) AS d0, sum(r[2]) AS d1, sum(r[3]) AS d7
FROM (
SELECT player_id, retention(
toDate(ts) = '2026-09-01',
toDate(ts) = '2026-09-02',
toDate(ts) = '2026-09-08') AS r
FROM events
WHERE toDate(ts) IN
('2026-09-01', '2026-09-02', '2026-09-08')
GROUP BY player_id);
What the result should be
d0 d1 d7
55860 31192 31366
D1 = 31192 / 55860 ≈ 56 %
D7 = 31366 / 55860 ≈ 56 %
retention()
Synthetic data
Cohort
r[1] — the first condition is met; r[i] — the first and i-th conditions are both met. A player without a Day 0 is not counted.
The players were selected at random, so D1 ≈ D7. In this particular game, D7 is significantly lower than D1.
Here, d0 refers to those active as of September 1. The registration cohort retrieves the date from the players table in PostgreSQL.
Withholding is determined based on the words used prior to the request. Which day is considered day zero, what counts as a return, and which time zone applies: document this as a flowchart.