I have this query:
select '2012-Nov-01' As "Week_Of",
count(player_id) as cohort_size ,
count(case
when trunc(init_dtime)-trunc(create_dtime) >= 0
then player_id
end) as Day_0_Ret,
count(case
when trunc(init_dtime)-trunc(create_dtime) >= 1
then player_id
end) as Day_1_Ret,
count(case
when trunc(init_dtime)-trunc(create_dtime) >= 2
then player_id
end) as Day_2_Ret,
count(case
when trunc(init_dtime)-trunc(create_dtime) >= 3
then player_id
end) as Day_3_Ret
from player
where trunc(create_dtime) > To_Date('2012-Nov-01','yyyy-mon-dd')-7
and trunc(create_dtime) <= To_Date('2012-Nov-01','yyyy-mon-dd')
and world_flag != '1'
Which outputs:
Week_Of Cohort_size Day_0_Ret Day_1 Ret Day_2_Ret Day_3_Ret
2012-Nov-01 2426 2426 1412 1349 1316
I want to be able to run this query for multiple sets of dates, so that my output would look something like:
Week_Of Cohort_size Day_0_Ret Day_1 Ret Day_2_Ret Day_3_Ret
2012-Nov-01 2426 2426 1412 1349 1316
2012-Nov-08 5106 2458 1945 1379 1248
2012-Nov-15 3580 1476 1412 1349 1146
Instead of having the re run the query everytime for a specific week of. Is this possible?
UNIONthen together and thenINNER JOINthe result with your query.