题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
https://www.nowcoder.com/practice/126083961ae0415fbde061d7ebbde453
select sum(case when datediff(t.py,t.date)=1 then 1 else 0 end)/ count(distinct device_id,date) from( select id,device_id,date, lead(date,1)over(partition by device_id order by date) as py from question_practice_detail ) as t 唯一难点在于,不知道那个平均后来才知道,每个人每天的天数,不是全部时间