Query editor
withtoken_transfer as (select *from query_4571732)SELECTdate_trunc('{{time period}}', block_time) AS time,tr.deposit_type AS source,SUM(amount) AS net_token_deposit,SUM(CASE WHEN transfer_type = 'deposit' THEN amount ELSE 0 END) AS token_deposit,SUM(CASE WHEN transfer_type = 'withdraw' THEN amount ELSE 0 END) AS token_withdraw,SUM(SUM(amount)) OVER (PARTITION BY tr.deposit_type ORDER BY date_trunc('{{time period}}', block_time)) AS net_token_deposit_cumulative,SUM(SUM(CASE WHEN transfer_type = 'deposit' THEN amount ELSE 0 END)) OVER (PARTITION BY tr.deposit_type ORDER BY date_trunc('{{time period}}', block_time)) AS token_deposit_cumulative,SUM(SUM(CASE WHEN transfer_type = 'withdraw' THEN amount ELSE 0 END)) OVER (PARTITION BY tr.deposit_type ORDER BY date_trunc('{{time period}}', block_time)) AS token_withdraw_cumulative,SUM(amount_usd) AS net_usd_deposit,SUM(CASE WHEN transfer_type = 'deposit' THEN amount_usd ELSE 0 END) AS usd_deposit,SUM(CASE WHEN transfer_type = 'withdraw' THEN amount_usd ELSE 0 END) AS usd_withdraw,SUM(SUM(amount_usd)) OVER (PARTITION BY tr.deposit_type ORDER BY date_trunc('{{time period}}', block_time)) AS net_usd_deposit_cumulative,SUM(SUM(CASE WHEN transfer_type = 'deposit' THEN amount_usd ELSE 0 END)) OVER (PARTITION BY tr.deposit_type ORDER BY date_trunc('{{time period}}', block_time)) AS usd_deposit_cumulative,SUM(SUM(CASE WHEN transfer_type = 'withdraw' THEN amount_usd ELSE 0 END)) OVER (PARTITION BY tr.deposit_type ORDER BY date_trunc('{{time period}}', block_time)) AS usd_withdraw_cumulativeFROMtoken_transfer trWHEREdate_trunc('{{time period}}', block_time) >= CAST('{{start date}}' AS TIMESTAMP)GROUP BY1, 2ORDER BY1 DESC