【问题标题】:Retention Rate within Cohort队列内的保留率
【发布时间】:2014-08-25 03:30:19
【问题描述】:

我想要对用户群进行一些同期群分析。我们有 2 个表“注册”和“会话”,其中用户和会话都有一个“日期”字段。我正在寻找生成一个数字表(带有一些空白)的查询,该表向我显示:在特定日期创建帐户的用户计数并且还创建了一个会话,表明他在那天返回、第 3 天、第 7 天和第 14 天。

created_at d1 d3 d7 d14
05/07/2007 12 * * *
04/07/2007 49 21 1 2
03/07/2007 45 30 * 3
02/07/2007 47 41 18 12

... 在这种情况下,2007 年 2 月 7 日创建帐户的 47 位用户在 3 天后返回(d3)

我可以在单个 MySQL 查询中执行此操作吗?

【问题讨论】:

    标签: retention


    【解决方案1】:

    是的,你可以:

    Select Signups.date as created at, 
    count (distinct case when datediff(sessions.date, signups.date)=1 then signups.users else null end) as d1,
    count (distinct case when datediff(sessions.date, signups.date)=3 then signups.users else null end) as d3,
    count (distinct case when datediff(sessions.date, signups.date)=7 then signups.users else null end) as d7,
    count (distinct case when datediff(sessions.date, signups.date)=14 then signups.users else null end) as d14 from signups
    left join sessions using(users)
    group by 1
    

    【讨论】:

    • 我没有成功,请澄清
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 2019-07-15
    • 1970-01-01
    • 2021-06-03
    • 1970-01-01
    相关资源
    最近更新 更多