Query editor
-- Trending Tokens - 24Hr & 48Hr Comparison - Solanawith base_token_prices as(select * from query_4215969where (contract_address not in ('So11111111111111111111111111111111111111112'))),base_transfers as (SELECT-- a.blockchain,a.block_time,a.block_date,a.tx_id as tx_hash,a.token_mint_address AS contract_address,cast(a.amount as double)/conversion as quantity,(cast(a.amount as double)/conversion)*price as volume,b.price,max(block_time) over(partition by a.token_mint_address) as last_transaction_atFROM (select block_time, block_date, tx_id, token_mint_address, amount from tokens_solana.transferswhere block_date > cast(date_add('day', -2, now()) as timestamp)-- where block_date > cast(date_add('day', -3, now()) as timestamp)and token_mint_address not in ('So11111111111111111111111111111111111111112')) as aleft join base_token_prices b on a.block_date = b.block_date and a.token_mint_address = b.contract_addressWHERE 1=1and a.block_time > CAST(NOW() - INTERVAL '2' day as timestamp)-- and a.block_time > CAST(NOW() - INTERVAL '3' day as timestamp)and b.contract_address is not nulland conversion>0)-- select distinct contract_address from base_transfers-- where block_date = TRY_CAST(now() AS DATE)-- and price is not null,base_time_diff as(select *, date_diff('hour', block_time, last_transaction_at) as diff_hours from base_transfers),base_summary as(select-- blockchain,contract_address,max(block_date) as max_block_date,max(last_transaction_at) as last_transaction_at,count(distinct case when diff_hours >= 0 and diff_hours < 6 then tx_hash end) as transactions_0_24h,count(distinct case when diff_hours >= 6 and diff_hours < 12 then tx_hash end) as transactions_24_48h,sum(case when diff_hours >= 0 and diff_hours < 6 then volume end) as volume_0_24h,sum(case when diff_hours >= 6 and diff_hours < 12 then volume end) as volume_24_48h,-- max(case when diff_hours >= 0 and diff_hours < 4 then price end) as median_price_0_24h,-- max(case when diff_hours >= 4 and diff_hours < 8 then price end) as median_price_24_48happrox_percentile(case when diff_hours >= 0 and diff_hours < 6 then price end, 0.5) as median_price_0_24h,approx_percentile(case when diff_hours >= 6 and diff_hours < 12 then price end, 0.5) as median_price_24_48hfrom base_time_diffwhere volume > 0-- group by 1,2