题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
http://www.nowcoder.com/practice/126083961ae0415fbde061d7ebbde453
select count(t3.device_id)/count(t2.device_id) as avg_ret from (select t1.*,date_add(t1.date,interval 1 day) as diertian from (select distinct device_id,date from question_practice_detail ) as t1) as t2 left join (select distinct device_id,date from question_practice_detail) as t3 on t2.device_id=t3.device_id and t2.diertian=t3.date;