题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
http://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.device_id=t2.device_id and t1.date=DATE_ADD(t2.date,INTERVAL 1 day);