Query editor
with s as (SELECTCASEWHEN token_pair IS NULL THENCASEWHEN token_bought_address > token_sold_address THENCONCAT(SUBSTRING(token_sold_address,1, 6), '-', SUBSTRING(token_bought_address,1, 6))ELSECONCAT(SUBSTRING(token_bought_address,1, 6), '-', SUBSTRING(token_sold_address,1, 6))ENDELSE token_pairENDAS active_pairs,CONCAT('<a href=https://app.roninchain.com/address/',project_contract_address,' target=_blank">',CASEWHEN token_pair IS NULL THENCASEWHEN token_bought_address > token_sold_address THENCONCAT(SUBSTRING(token_sold_address,1, 6), '-', SUBSTRING(token_bought_address,1, 6))ELSECONCAT(SUBSTRING(token_bought_address,1, 6), '-', SUBSTRING(token_sold_address,1, 6))ENDELSE token_pairEND,'</a>') AS active_pair_links, COALESCE(SUM(amount_usd),0) AS total_volume,COUNT(DISTINCT tx_hash) as num_txs, COUNT(DISTINCT tx_from) AS active_traders,COALESCE(SUM(amount_usd),0)/COUNT(DISTINCT tx_from) as vol_to_trader_ratio,COALESCE(SUM(amount_usd),0)/COUNT(DISTINCT tx_hash) as vol_to_tx_ratioFROM (SELECTblock_time, amount_usd, CAST(tx_from AS VARCHAR) AS tx_from, token_pair,CAST(tx_hash as VARCHAR) as tx_hash, CAST(project_contract_address AS VARCHAR) AS project_contract_address, CAST(token_bought_address AS VARCHAR) AS token_bought_address, CAST(token_sold_address AS VARCHAR) AS token_sold_addressFROM dex.tradesWHERE 1=1AND blockchain = 'ronin'AND project = 'katana'AND token_bought_address = 0xe514d9deb7966c8be0ca922de8a064264ea6bcd4 or token_sold_address = 0xe514d9deb7966c8be0ca922de8a064264ea6bcd4) subqueryGROUP BY 1,2)selectactive_pairs as "Active Pairs",active_pair_links as "Active Pairs Link",total_volume as "Total Trade Volume (USD)",num_txs as "Total Transactions",active_traders as "Active Traders",vol_to_trader_ratio as "Volume to trader ratio",vol_to_tx_ratio as "Volume to transaction ratio"