我有这个查询
--Retention by DOC,Users created >= Jan 1,2012--
Select
One.Date_Of_Concern,
Two.Users,
One.Retained,
Round(One.Retained/Two.Users,4) as Perc_Retained
From
(
Select
To_Date('2012-sep-09','yyyy-mon-dd')As Date_Of_Concern,
Count(P.Player_Id) As Retained
From Player P
Where
Trunc(P.Create_Dtime) >= To_Date('2012-Jan-01','yyyy-mon-dd')
And
(To_Date('2012-sep-09','yyyy-mon-dd')-Trunc(P.Init_Dtime))<=7
) One
Inner Join
(
Select
To_Date('2012-sep-09','yyyy-mon-dd')As Date_Of_Concern,
Count(P.Player_Id) As Users
From Player P
Where
Trunc(P.Create_Dtime) >= To_Date('2012-Jan-01','yyyy-mon-dd')
) Two On One.Date_Of_Concern = Two.Date_Of_Concern
这给了我 1 行的结果:
Date_Of_Concern USERS RETAINED PERC_RETAINED
09-Sep-12 449773 78983 0.1756
我想通过添加某种日期更改方法来改进此查询。这样,我就不必每次都为 09-sep-12、10-sep-12、11-sep-12 等运行查询。相反,它将全部显示在同一个查询中,如下所示:
Date_Of_Concern USERS RETAINED PERC_RETAINED
09-Sep-12 449773 48783 0.1756
10-Sep-12 449773 46777 0.1600
11-Sep-12 440773 44852 0.1500
12-Sep-12 349773 42584 0.1400