Query editor
WITH v1 AS (SELECT date_trunc('month', evt_block_time) as month, 'V1' as version, SUM(CAST(cashbackInUsd AS DOUBLE) / 1e6) as cashback_usd, SUM(CAST(spendingInUsd AS DOUBLE) / 1e6) as spend_usd, COUNT(*) as events, COUNT(DISTINCT userSafe) as users FROM etherfi_scroll.usersafeeventemitter_evt_cashback WHERE paid = true GROUP BY 1), v3 AS (SELECT date_trunc('month', evt_block_time) as month, 'V3' as version, SUM(CAST(cashbackInUsd AS DOUBLE) / 1e6) as cashback_usd, SUM(CAST(spendingInUsd AS DOUBLE) / 1e6) as spend_usd, COUNT(*) as events, COUNT(DISTINCT safe) as users FROM etherfi_scroll.usersafeeventemitterv3_evt_cashback WHERE paid = true GROUP BY 1) SELECT COALESCE(v1.month, v3.month) as month, COALESCE(v1.cashback_usd, 0) + COALESCE(v3.cashback_usd, 0) as total_cashback, COALESCE(v1.spend_usd, 0) + COALESCE(v3.spend_usd, 0) as total_spend, COALESCE(v1.events, 0) + COALESCE(v3.events, 0) as total_events, COALESCE(v1.users, 0) + COALESCE(v3.users, 0) as total_users, v1.cashback_usd as v1_cashback, v3.cashback_usd as v3_cashback FROM v1 FULL OUTER JOIN v3 ON v1.month = v3.month ORDER BY 1