Query editor
with dataTable as (selectdate_trunc('day',block_time) as datestamp,count (casewhen token_bought_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'then 1end) as buyTrades,count (distinct casewhen token_bought_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'then trader_idend) as buyDistinct,count(casewhen token_sold_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'then 1end) as sellTrades,count(distinct casewhen token_sold_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'then trader_idend) as sellDistinctfrom dex_solana.tradeswhere(token_bought_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'or token_sold_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm')and date_trunc('day',block_time) > now() - interval '60' daygroup by date_trunc('day',block_time)order by date_trunc('day',block_time) desc), netbuys as (selectdatestamp as day, buyTrades-sellTrades as net_buys_tx, buyDistinct-sellDistinct as net_buys_tradersfrom dataTable), hourly_price as (select date_trunc('hour', block_time) as hour, case when token_bought_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'then (amount_usd/token_bought_amount)else (amount_usd/token_sold_amount) end as pricefrom dex_solana.tradeswhere block_time >= DATE_TRUNC('day', CURRENT_DATE) - INTERVAL '60' DAYand (token_bought_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'or token_sold_mint_address ='EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm')and amount_usd > 0and token_bought_amount > 0and token_sold_amount > 0order by 1 desc), hourly_price_f as (select hour, avg(price) as pricefrom hourly_pricegroup by 1), daily_price as (select date_trunc('day', hour) as day, avg(price) as pricefrom hourly_price_fgroup by 1)---final join