Query editor
withtoken AS(SELECT date_trunc('day', minute) AS date1 , avg(price) AS price, decimals, bytearray_substring(contract_address, 1, 20) as p_contract_address, symbolFROM prices.usdWHERE blockchain = 'ethereum' and minute > now() - interval '1' month and contract_address != 0x587c16b84c64751760f6e3e7e32f896634704352 and contract_address != 0x7ddee176f665cd201f93eede625770e2fd911990GROUP BY 1, 3, 4, 5),txs AS(SELECT date_trunc('day', block_time) AS date2,REPLACE(bytearray_substring(topic1, 13, 20), 0x0000000000000000000000000000000000000000,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) AS token_contract,bytearray_to_uint256(bytearray_substring(data, 1, 32)) as vol,tx_hashFROM ethereum.logsWHERE block_time > now() - interval '1' monthAND (contract_address = 0x07964f135f276412b3182a3b2407b8dd45000000)AND topic0 = 0x2251435bd151cd72851a82be055bf6d1c3d7f34d08d56493dddf874229b8e897AND bytearray_substring(data, 95, 2) = 0x0000ORDER BY 1 desc)SELECT txs.date2,token.symbol,token.decimals,token.p_contract_address,-- sum(txs.vol) as vol_usd,sum( (cast(txs.vol as double) / pow(10, token.decimals) * token.price) ) AS vol_usd,count(txs.tx_hash) AS tx_countFROM txsINNER JOIN tokenON token.p_contract_address = txs.token_contractAND token.date1 = txs.date2GROUP BY 1, 2, 3, 4ORDER BY 1 DESC, 5 desc