1
select retention
 , Sum(count(retention)) over(order by retention desc) as Num_Users_Retained
  from (select player_id
         , round(init_dtime-create_dtime,0) as retention
      from player
     where Trunc(Create_Dtime) >= To_Date('2012-jan-01','yyyy-mon-dd')
       and init_dtime is not null)
  Group by retention
  order by retention

此查询显示两列:第一列是今年的日期(第 0 天是 1 月 1 日,第 259 天是今天 9 月 16 日),第二列是保留。第 0 天有 428,000,因为所有用户都被保留,第 1 天有 300K(因为有 128,000 人在第一天后没有登录),随着时间的推移,这个数字不断减少。我想为第 0 天的每一天的百分比显示另一列。这足够清楚还是我应该提供更多细节?

4

1 回答 1

2
select retention
     , Num_Users_Retained
     , round(Num_Users_Retained/max(Num_Users_Retained) over() * 100, 2) as perc
  from (select retention
             , Sum(count(retention)) over(order by retention desc) as Num_Users_Retained
         from (select player_id
                    , round(init_dtime-create_dtime,0) as retention
                from player
               where Trunc(Create_Dtime) >= To_Date('2012-jan-01','yyyy-mon-dd')
                 and init_dtime is not null
              )
        Group by retention
        order by retention)
 order by retention
于 2012-09-17T05:48:42.107 回答