#查看用户 在某天刷题后 第二天 还会再来刷题的 留存率
#临时表查询——with 表名 as ( ... )
with tmp
as(
    select device_id , date
    from question_practice_detail
    group by 1,2     #去重
)

select count(b.device_id)/count(a.device_id) as avg_ret
from tmp a
left join tmp b
on a.device_id = b.device_id
   and a.date = date_sub(b.date , interval 1 day) #前一天与后一天