Query editor
WITH TransferEvents AS (SELECTt.evt_block_time,t.evt_tx_hash,t.evt_index,t.contract_address,t.value / 1e18 AS token_amount,SUM(t.value / 1e18) OVER (ORDER BY t.evt_block_time, t.evt_tx_hash, t.evt_index) AS token_amount_accumulatedFROM erc20_ethereum.evt_Transfer tWHERE t."to" = 0xD8b27CF359b7D15710a5BE299AF6e7Bf904984C2AND t."from" = 0xa680FeDa11FbbB18a759A60756b2E7B51A5f452F),LatestPrices AS (SELECTp.contract_address,p.price,p.symbol AS erc20,RANK() OVER (PARTITION BY p.contract_address ORDER BY p.minute DESC) AS rnkFROM prices.usd p),JoinedData AS (SELECTe.evt_block_time,e.evt_tx_hash,e.evt_index,e.contract_address,lp.erc20,e.token_amount AS amount,(e.token_amount * lp.price) AS usd_value,SUM(e.token_amount * lp.price) OVER (ORDER BY e.evt_block_time, e.evt_tx_hash, e.evt_index) AS usd_value_accumulated,e.token_amount_accumulatedFROM TransferEvents eJOIN LatestPrices lpON e.contract_address = lp.contract_addressWHERE lp.rnk = 1)SELECTevt_block_time,evt_tx_hash,evt_index,contract_address,erc20,amount,usd_value,usd_value_accumulated,token_amount_accumulatedFROM JoinedDataORDER BY evt_block_time DESC, evt_tx_hash DESC, evt_index DESC;