Query editor
withall_cex as (selectaddress,cex_name as namefrom addresses_ethereum.cexwhere cex_name in ('Binance', 'FTX', 'Coinbase', 'OKX', 'Huobi', 'Gate.io', 'Kraken', 'Bitfinex', 'KuCoin', 'Crypto.com', 'Gemini')unionselectaddress,cex_name as namefrom cex.addresseswhere cex_name in ('Binance', 'FTX', 'Coinbase', 'OKX', 'Huobi', 'Gate.io', 'Kraken', 'Bitfinex', 'KuCoin', 'Crypto.com', 'Gemini')),CEX as (selectDISTINCT address, name from all_cex),inflow_usdt as (SELECTdate_trunc('week', t."evt_block_time") AS time,SUM(CAST(t."value" AS DOUBLE)/1e18) AS amount_receivedFROM erc20_ethereum.evt_Transfer tleft join cex c on c.address = t."to"WHERE "to" in (select address from CEX)AND t.evt_block_time >= NOW() - interval '196' dayAND contract_address in (0xdac17f958d2ee523a2206206994597c13d831ec7 --USDT)GROUP BY 1union allSELECTdate_trunc('week', t."evt_block_time") AS time,SUM(CAST(t."value" AS DOUBLE)/1e18) AS amount_receivedFROM erc20_bnb.evt_Transfer tleft join cex c on c.address = t."to"WHERE "to" in (select address from CEX)AND t.evt_block_time >= NOW() - interval '196' dayAND contract_address in (0x55d398326f99059ff775485246999027b3197955 --BUSD)GROUP BY 1union allSELECTdate_trunc('week', t."evt_block_time") AS time,SUM(CAST(t."value" AS DOUBLE)/1e18) AS amount_receivedFROM erc20_arbitrum.evt_Transfer tleft join cex c on c.address = t."to"WHERE "to" in (select address from CEX)AND t.evt_block_time >= NOW() - interval '196' dayAND contract_address in (0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 --USDT