题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
https://www.nowcoder.com/practice/126083961ae0415fbde061d7ebbde453
SELECT round(count(b.device_id)/count(a.device_id), 4) as avg_ret FROM (SELECT distinct device_id, date FROM question_practice_detail) as a left join (SELECT distinct device_id, date FROM question_practice_detail) as b on a.device_id = b.device_id and a.date = DATE_ADD(b.date,interval 1 day);