Query editor
withbase as (select *from query_4118294),name_mint as (select *from basewhere event = 'mint'),latest_transfer as (select blockchain,contract_address,tokenId,max(evt_block_number) as latest_block_number, -- 找出每个tokenId的最新区块号max(evt_index) as latest_evt_index -- 如果同一块区块有多个事件,找出最后一笔from basegroup by blockchain, contract_address, tokenId),current_holder as (select t.blockchain,t.tokenId,t.to as holder,t.evt_block_time as last_transfer_timefrom base tjoin latest_transfer lton t.contract_address = lt.contract_addressand t.tokenId = lt.tokenIdand t.evt_block_number = lt.latest_block_numberand t.evt_index = lt.latest_evt_index)selectcoalesce(a.blockchain, 'total') as blockchain, -- 使用 coalesce 显示 'Total' 作为汇总行sum(total_mints) as total_mints,sum(total_users) as total_users,sum(total_holders) as total_holdersfrom(select blockchain, count(distinct tokenId) as total_mints from name_mint group by blockchain) ajoin(select blockchain, count(distinct to) as total_users from base group by blockchain) b on b.blockchain = a.blockchainjoin(select blockchain, count(distinct holder) as total_holders from current_holder group by blockchain) c on c.blockchain = a.blockchaingroup by rollup(a.blockchain) -- 使用 ROLLUP 来生成汇总行order by a.blockchain