题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
https://www.nowcoder.com/practice/126083961ae0415fbde061d7ebbde453
--熟悉LEFT JOIN / DATE_ADD() 等语句和函数的运用 SELECT COUNT(q2.device_id) / COUNT(q1.device_id) AS avg_ret FROM (SELECT DISTINCT device_id,date FROM question_practice_detail) AS q1 LEFT JOIN (SELECT DISTINCT device_id,date FROM question_practice_detail) AS q2 ON q1.device_id = q2.device_id AND q2.date = DATE_ADD(q1.date, INTERVAL 1 DAY)