sql29专题

SQL29 计算用户的平均次日留存率(lead函数的用法)

代码 with t1 as(select distinct device_id,date --去重防止单日多次答题的情况from question_practice_detail)selectavg(if(datediff(date2,date1)=1,1,0)) as avg_retfrom (selectdistinct device_id,date as date1,lead(