美文网首页
SQL案例:新用户次日留存

SQL案例:新用户次日留存

作者: 无敌的肉包 | 来源:发表于2018-07-15 21:10 被阅读0次

新用户的次日留存率
表结构

|uuid|is_new|   day   |platform|
|----|------|---------|--------|
| 1  | 1    | 20180714| iphone |
| 2  | 0    | 20180715| Android|
| 1  | 1    | 20180715| iphone |
| 4  | 0    | 20180715| Android|
SELECT t.platform,COUNT(nt.uuid) AS RemainUserNextDay,COUNT(t.uuid) AS NewUserCount ,COUNT(nt.uuid)*1.0/COUNT(t.uuid) AS RemainRateNextDay
FROM t AS t
LEFT JOIN t AS nt ON t.platform=nt.platform and nt.uuid=t.uuid AND DATEDIFF(d,t.[day],nt.[day])=1 AND nt.is_new=0
WHERE t.is_new=1
GROUP BY t.platform


相关文章

网友评论

      本文标题:SQL案例:新用户次日留存

      本文链接:https://www.haomeiwen.com/subject/idqmpftx.html