题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
https://www.nowcoder.com/practice/126083961ae0415fbde061d7ebbde453
select count(t2.device_id) / count(t1.device_id) avg_ret from (select distinct device_id, date from question_practice_detail ) t1 left join (select distinct device_id, date from question_practice_detail) t2 on t1.date + 1 = t2.date and t1.device_id = t2.device_id
同一张表与自己连接
连接条件:同一个人前一天答题并且第二天也答题的
计算方式:表连接后第二天答题人数/前一天答题人数