Query editor
withtoshi_daily_volume as(select day, sum(buy_amount) as daily_buy_amount,sum(sell_amount) as daily_sell_amount from (selectdate_trunc('day',block_time) as day,case when token_bought_address = 0xac1bd2486aaf3b5c0fc3fd868558b082a531b2b4 then amount_usd end as buy_amount,case when token_sold_address = 0xac1bd2486aaf3b5c0fc3fd868558b082a531b2b4 then amount_usd end as sell_amountfromdex.tradeswheredate_trunc('day',block_time)> TIMESTAMP '2023-10-09') --token launchgroup by 1),toshi_price as(select date_trunc('day',hour) as day,min(median_price) as price from dex.prices where contract_address=0xAC1Bd2486aAf3B5C0fc3Fd868558b082a531B2B4group by 1),cum_volume as (select vol.day, daily_buy_amount, daily_sell_amount,price,sum(daily_buy_amount) over (order by vol.day) as cum_buy_volume,sum(daily_sell_amount) over (order by vol.day) as cum_sell_volumefrom toshi_daily_volume vol join toshi_price p on vol.day=p.day)select day, daily_buy_amount, daily_sell_amount,price,cum_buy_volume, cum_sell_volume,cum_buy_volume+cum_sell_volume as cumulative_volume,round((cum_buy_volume+cum_sell_volume)/1000000) as resultfrom cum_volumeorder by day desc