Я считаю, что это запрос, который вам нужен:
SELECT date_part('month', signup_date) as month
, count(DISTINCT(p.cage_player_id)) as active
, (select count(cage_player_id)
FROM player_signup as p
GROUP BY date_part('month', p.signup_date)) as total
FROM player_signup as p
JOIN daily_kpis as d ON p.cage_player_id = d.cage_player_id
WHERE slot_bet_amount > 0
OR ld_bet_amount > 0
OR table_bet_amount > 0
GROUP BY date_part('month', p.signup_date)
ORDER BY date_part('month', p.signup_date) asc
Я не так хорош в Postgresql, пожалуйста, попробуйте это:
SELECT date_part('month', signup_date) as month
, count(DISTINCT(p.cage_player_id)) as active
, max(t1.total) as total
FROM player_signup as p
left join (select count(pp.cage_player_id) over (partition by date_part('month', pp.signup_date)) as total
, date_part('month', pp.signup_date) date_p
FROM player_signup as pp) t1 on t1.date_p = date_part('month', p.signup_date)
JOIN daily_kpis as d ON p.cage_player_id = d.cage_player_id
WHERE slot_bet_amount > 0
OR ld_bet_amount > 0
OR table_bet_amount > 0
GROUP BY date_part('month', p.signup_date)
ORDER BY date_part('month', p.signup_date)