Query editor
WITH trading_data AS (SELECTdate_trunc('day', block_time) AS day,tx_from AS wallet,SUM(amount_usd) AS daily_volume,CASEWHEN SUM(amount_usd) <= {{micro_transaction_threshold_USD}} THEN TRUEELSE FALSEEND AS is_micro_transactionFROM dex.tradesWHEREblockchain = 'base'AND (token_bought_address = {{contract_address}} OR token_sold_address = {{contract_address}})AND block_time >= date_trunc('day', now()) - interval '{{n}}' dayGROUP BY 1, 2),daily_volumes AS (SELECTday,SUM(daily_volume) AS total_volume,SUM(CASE WHEN is_micro_transaction THEN daily_volume ELSE 0 END) AS micro_tx_volumeFROM trading_dataGROUP BY 1)SELECTday,total_volume,micro_tx_volume,micro_tx_volume / total_volume * 100 AS micro_tx_percentageFROM daily_volumesORDER BY day DESC