题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
https://www.nowcoder.com/practice/126083961ae0415fbde061d7ebbde453
with tmp as (select distinct device_id,date from question_practice_detail order by device_id,date) select (select count(t2.device_id) from tmp t1 left join tmp t2 on t1.device_id = t2.device_id and datediff(t2.date,t1.date) = 1 ) / count(device_id) from tmp;