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天是今天sep-16),第二列是保留。第0天有428,000個,因爲所有用戶都被保留,第1天有300K(因爲128K人在他們第一天後沒有登錄),並且隨着時間的推移,這個數字一直在減少。我想爲每天的第0天的百分比顯示另一列。是否足夠清楚,還是應該提供更多詳細信息?SQL - 以百分比顯示結果
確定列出的查詢是您的實際查詢嗎? –
@FlorinGhita是的,這正是查詢,我再次運行它來驗證。 – Americo