Query editor
with multichain_address as (select*fromdune.shellxu.result_big_fish_address_balance_bscunion allselect*fromdune.xyn008.result_big_fish_address_balance_ethereumunion allselect*fromdune.shell525.result_big_fish_address_balance_polygon),customer_agg as (selectcustomer_id,array_distinct(array_agg(address)) address,array_distinct(array_agg(cex_label)) cex_label,array_distinct(array_agg(withdrawl_address)) withdrawl_address,array_distinct(array_agg(deposit_address)) deposit_address,sum(if(cex_label is null and contract_label is null, balance_amount, 0)) not_cex_balance,count(distinct if(cex_label is null and contract_label is null, address, null)) not_cex_addr_cnt,count(distinct if(cex_label is not null and contract_label is null, address, null)) cex_addr_cnt,sum(if(cex_label is null and contract_label is null, tx_cnt, 0)) not_cex_tx_cnt,sum(if(cex_label is null and contract_label is null, addr_cnt, 0)) not_cex_tx_addr_cnt,round(sum(if(cex_label is null and contract_label is null, tx_amt, 0)),2) not_cex_tx_amt,sum(if(cex_label is null and contract_label is null, cex_cnt, 0)) not_cex_cnt,sum(if(cex_label is null and contract_label is null, binance_cnt, 0)) not_cex_binance_cnt,sum(if(cex_label is null and contract_label is null, mercado_cnt, 0)) not_cex_mercado_cnt,sum(if(cex_label is null and contract_label is null, contract_cnt, 0)) not_cex_contract_cntfrommultichain_addressgroup by1),multi_address as (selectaddress,count(distinct customer_id) cid_count,array_distinct(array_agg(customer_id)) customer_listfrommultichain_addressgroup by1havingcount(distinct customer_id) > 1),cex_label as (selectaddress,name cex_labelfromlabels.addresseswhere