题解 | #计算用户的平均次日留存率#
计算用户的平均次日留存率
https://www.nowcoder.com/practice/126083961ae0415fbde061d7ebbde453
select (sum(if(d=d1,1,0)))/count(device_id) from ( select device_id, lead(date,1,0)over(partition by device_id) d, date_format(date+1,'%Y-%m-%d')as d1 from ( select distinct device_id,date from question_practice_detail order by device_id,date )a )b