题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
http://www.nowcoder.com/practice/126083961ae0415fbde061d7ebbde453
select
count(q2.device_id)/ count(q1.device_id) avg_ret
from(
select distinct device_id
,date
from question_practice_detail
) q1
left join (
select distinct device_id
,date
from question_practice_detail
) q2
on q1.device_id=q2.device_id
count(q2.device_id)/ count(q1.device_id) avg_ret
from(
select distinct device_id
,date
from question_practice_detail
) q1
left join (
select distinct device_id
,date
from question_practice_detail
) q2
on q1.device_id=q2.device_id
and q2.date=date_add(q1.date,interval 1 day)
这题需要掌握。