Query editor
With info as (select blockchain, version, block_time, token_bought_symbol, token_sold_symbol, token_pair, token_bought_amount, token_sold_amount, amount_usd, token_bought_address, token_sold_address, taker, maker,project_contract_address, tx_hashfrom dex.trades where project = 'uniswap'),tokens AS (SELECTtoken_bought_symbol AS symbol,amount_usd,tx_hashFROMinfoWHEREblock_time > DATE '2020-06-29'UNION ALLSELECTtoken_sold_symbol AS symbol,amount_usd,tx_hashFROMinfoWHEREblock_time > DATE '2020-06-29'),RankedTokens AS (SELECTsymbol,SUM(amount_usd) AS USD_Volume,approx_distinct(tx_hash) AS tx_count,ROW_NUMBER() OVER (ORDER BY SUM(amount_usd) DESC) AS rankFROMtokensGROUP BYsymbol),Top5 AS (SELECTSUM(USD_Volume) AS top5Volume,SUM(cast(tx_count as double)) AS top5TxFROMRankedTokensWHERErank <= 5),TotalVolume AS (SELECTSUM(USD_Volume) AS totalVolume,SUM(cast(tx_count as double)) AS totalTxFROMRankedTokens)SELECTt5.top5Volume / tv.totalVolume * 100 AS top5_to_total_ratio,t5.top5Tx / tv.totalTx * 100 AS top5_tx_total_ratioFROMTop5 t5,TotalVolume tv