Query editor
with table_details as(select block_date, date_trunc('minute',block_time) as time_minute, block_time, amount_usd as usd_amount, token_bought_amount as token_amountfrom dex.trades where blockchain = 'bnb' and token_bought_address = 0x6d5ad1592ed9d6d1df9b93c793ab759573ed6714and amount_usd is not nullunion allselect block_date, date_trunc('minute',block_time) as time_minute,block_time, amount_usd as usd_amount, token_sold_amount as token_amountfrom dex.trades where blockchain = 'bnb' and token_sold_address = 0x6d5ad1592ed9d6d1df9b93c793ab759573ed6714and amount_usd is not null),table_hour_1 as (select time_minute, sum(usd_amount) as total_usd_amount , sum(token_amount) as total_token_amount from table_details group by time_minute),table_hour_2 as (select time_minute, total_usd_amount / total_token_amount as avg_price from table_hour_1),table_price as (select time_minute, avg_price from table_hour_2 order by avg_price desc limit 1)select time_minute, avg_price * 1e9 as max_market_cap from table_price