]> de.git.xonotic.org Git - xonotic/xonstatdb.git/blob - queries/player_retention_3months.sql
Add player retention query
[xonotic/xonstatdb.git] / queries / player_retention_3months.sql
1 -- how many distinct player_ids play in multiple months
2 select count(*) 
3 from players
4 where
5 player_id in (
6    select distinct player_id 
7    from player_game_stats 
8    where create_dt between (current_timestamp at time zone 'UTC' - interval '1 month') 
9                        and (current_timestamp at time zone 'UTC')
10 )
11 and player_id in (
12    select distinct player_id 
13    from player_game_stats 
14    where create_dt between (current_timestamp at time zone 'UTC' - interval '2 month') 
15                        and (current_timestamp at time zone 'UTC' - interval '1 month')
16 )
17 and player_id in (
18    select distinct player_id 
19    from player_game_stats 
20       where create_dt between (current_timestamp at time zone 'UTC' - interval '3 month') 
21                        and (current_timestamp at time zone 'UTC' - interval '2 month')
22 )
23 ;