### Session Time (VIP users)
with first_pass_cte as (
select event_date, user_id, session_id, sum(total_time_ms/1000./60.) as session_time_minutes
from fact_user_sessions_day_live
where player_start_date >= '2020-03-24' and player_start_date <= '2020-04-14'
group by event_date, session_id, user_id
)
select event_date, user_id, sum(case when session_time_minutes < 480 then session_time_minutes else null end) as sum_session_time_minutes
from first_pass_cte
group by event_date, user_id
having sum(case when session_time_minutes < 480 then session_time_minutes else null end)<480
### Session Time (Non-VIP users)
with first_pass_cte as (
select event_date, user_id, session_id, sum(total_time_ms/1000./60.) as session_time_minutes
from fact_user_sessions_day_live
where player_start_date >= '2020-02-25' and player_start_date <= '2020-03-17'
group by event_date, session_id, user_id
)
select event_date, user_id, sum(case when session_time_minutes < 480 then session_time_minutes else null end) as sum_session_time_minutes
from first_pass_cte
group by event_date, user_id
having sum(case when session_time_minutes < 480 then session_time_minutes else null end)<480
### Purchases (VIP Users)
select userid, eventdate, realcurrencyamount, productID from events_live
inner join fact_user_sessions_day_live
on events_live.userid = fact_user_sessions_day_live.user_id
where player_start_date >= '2020-03-24' and player_start_date <= '2020-04-14'
and realcurrencyamount > 0
### Purchases (Non-VIP Users)
select userid, eventdate, realcurrencyamount, productID from events_live
inner join fact_user_sessions_day_live
on events_live.userid = fact_user_sessions_day_live.user_id
where player_start_date >= '2020-02-25' and player_start_date <= '2020-03-17'
and realcurrencyamount > 0