Query editor
WITH batches as (SELECT *, (num_trades*35)+50 as rewardFROM gnosis_protocol_v2.batcheswhere block_time > '2022-03-01'),result as (SELECTdate_trunc('{{Time interval}}', block_time) as time,count(num_trades) as batches,sum(num_trades) as trades,sum(gas_per_trade) trade_gas,sum(gas_used) batch_gas,sum(fee_value) as fee_value,sum(tx_cost_usd) as tx_cost,sum(reward) as rewards_v2FROM batchesGROUP BY time)SELECT *,batches*100 as rewards_v1,sum(batches*100) over (order by time asc rows between unbounded preceding and current row) as cumulative_rewards_v1,sum(rewards_v2) over (order by time asc rows between unbounded preceding and current row) as cumulative_rewards_v2FROM resultORDER BY time DESC