Query editor
WITHholders as (select token_balance_owner, sum(token_balance) as balancefrom solana_utils.latest_balanceswhere token_mint_address = '{{token_address}}'group by 1having sum(token_balance) > 0),supply as (select sum(balance) as supply from holders),decimals as (select decimals,created_atfrom tokens_solana.fungible where token_mint_address = '{{token_address}}'),datasales AS (SELECTblock_time,trader_id AS wallet, tx_id,amount_usd,amount_usd/token_sold_amount as token_price,token_sold_amount_raw/pow(10,(select decimals from decimals)) as amount,'sell' as actionFROM dex_solana.tradesWHEREtoken_sold_mint_address = '{{token_address}}'UNION ALLSELECTblock_time,trader_id AS wallet,tx_id,amount_usd,amount_usd/token_bought_amount as token_price,token_bought_amount_raw/pow(10,(select decimals from decimals)) as amount,'buy' as actionFROM dex_solana.tradesWHEREtoken_bought_mint_address = '{{token_address}}'),token_price as (select date_trunc('hour',block_time) as day_time,avg(token_price) as token_price from datasales where token_price is not nullgroup by 1order by 1 desc limit 1),txs as (select wallet,max(block_time) as max_date,count(distinct tx_id) as trades,sum(amount_usd) as tradevolume,avg(token_price) as avg_token_price,count(distinct (case when action = 'sell' then tx_id end)) as sell_tx,count(distinct (case when action = 'buy' then tx_id end)) as buy_tx,sum(case when action = 'sell' then amount end) as sell_amount,sum(case when action = 'buy' then amount end) as buy_amount,