用户留存
某段时间内的新增用户(活跃用户),经过一段时间后,又继续使用应用的被认作是留存用户; 这部分用户占当时新增用户(活跃用户)的比例即是留存率。例如,5月份新增用户200,这200人在6月份启动过应用的有100人,7月份启动过应用的有80人,8月份启动过应用的有50人;则5月新增用户一个月后的留存率是50%,两个月后的留存率是40%,三个月后的留存率是25%。

drop table if exists dwt_uv_topic;create external table dwt_uv_topic(`mid_id` string comment '设备id',`brand` string comment '手机品牌',`model` string comment '手机型号',`login_date_first` string comment '首次活跃时间',`login_date_last` string comment '末次活跃时间',`login_day_count` bigint comment '当日活跃次数',`login_count` bigint comment '累积活跃天数') COMMENT '设备主题宽表'stored as parquetlocation '/warehouse/gmall/dwt/dwt_uv_topic'tblproperties ("parquet.compression"="lzo");
--一天后留存
select
'2020-06-15',
date_add('2020-06-15',-1),
1,--留存天数
sum(if(login_date_first=date_add('2020-06-15',-1) and login_date_last='2020-06-15',1,0)),
sum(if(login_date_first=date_add('2020-06-15',-1),1,0)),
sum(if(login_date_first=date_add('2020-06-15',-1) and login_date_last='2020-06-15',1,0))/sum(if(login_date_first=date_add('2020-06-15',-1),1,0))*100
from dwt_uv_topic
留存率计算:
http://www.javashuo.com/article/p-gqerwpgd-sw.html
做用户增长时,如何做好新增用户的留存
https://zhuanlan.zhihu.com/p/47981091
用户活跃是运营的核心阶段
https://blog.csdn.net/winsonyuan/article/details/73332678
