I am trying to determine the players who played 'Chess' on Jan 7th 2021, what percentage played again the next day (Jan 8th)?
game_table
| column | data_type|
|:---- | -----:|
| user_id | BIGINT|
| date | STRING|
| game_name | STRING|
| session_count| BIGINT|
Here is my code but I don't think it is correct:
with t1 as
(select game_name, count(*) as count_jan7
from instant_game_sessions
where date = '2021-01-07' and game_name = 'Chess'
group by 1).
t2 as
(select games, count(*) as count_jan7_and_jan8
from instant_game_sessions
where date = '2021-01-07' and game_name = 'Chess' and date= '2021-01-08'
group by 1)
select cast(count_jan7_and_jan8 as numeric)/count_jan7 *100
from t1
join t2 on t1.game_name = t2.game_name