1/25/2018 - 4:06 PM

1 Day Retention KPI

More difficult to grasp in SQL, so separated from 'Basics of KPIs'.

\!h 1 Day Retention
-- How many players are returning to play the next day
  date(g1.created_at) as dt, 
  round(100 * count(distinct g2.user_id) / -- retained users / total users
    count(distinct g1.user_id)) as retention 
from gameplays as g1
  left join gameplays as g2 on
    g1.user_id = g2.user_id
    and date(g1.created_at) = date(datetime(g2.created_at, '-1 day'))
group by 1
order by 1
limit 100;