Query editor
with base as (select*from base.transactions), user_summary as (select"from" as user_address,count(*) as transaction_count,min(block_time) as initial_block_time,max(block_time) as last_block_time,date_diff('day', min(block_time), now()) as base_age_days,count(distinct date_trunc('day', block_time)) as active_days_count,count(distinct date_trunc('week', block_time)) as active_weeks_count,count(distinct date_trunc('month', block_time)) as active_months_count,sum(b.value*p.price)/power(10,18) as volumefrom base bleft join prices.usd pon date_trunc('minute', b.block_time) = p.minute and p.contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2group by 1),user_summary_with_rank as (select *,(+ if(active_months_count >= 2, 1, 0) -- Conducted transactions during 2 distinct months+ if(active_months_count >= 6 , 1, 0) -- Conducted transactions during 6 distinct months+ if(active_months_count >= 9, 1, 0) -- Conducted transactions during 9 distinct months+ if(active_months_count >= 12, 1, 0) -- Conducted transactions during 12 distinct months+ if(active_weeks_count >= 10, 1, 0) -- Conducted transactions during 10 distinct weeks+ if(active_weeks_count >= 20, 1, 0) -- Conducted transactions during 20 distinct weeks+ if(active_weeks_count >= 50, 1, 0) -- Conducted transactions during 50 distinct weeks+ if(active_weeks_count >= 100, 1, 0) -- Conducted transactions during 100 distinct weeks+ if(transaction_count >= 5, 1, 0) -- Conducted more than 5 transactions+ if(transaction_count >= 10, 1, 0) -- Conducted more than 10 transactions+ if(transaction_count >= 25, 1, 0) -- Conducted more than 25 transactions+ if(transaction_count >= 50, 1, 0) -- Conducted more than 50 transactions+ if(transaction_count >= 100, 1, 0) -- Conducted more than 100 transactions+ if(volume > 1000, 1, 0) -- Conducted more than $1000 worth of transactions+ if(volume > 10000, 1, 0) -- Conducted more than $10000 worth of transactions+ if(volume > 25000, 1, 0) -- Conducted more than $25000 worth of transactions+ if(volume > 50000, 1, 0) -- Conducted more than $50000 worth of transactions+ if(volume > 100000, 1, 0) -- Conducted more than $100000 worth of transactions) as rank_scorefrom user_summary)select row_number() over (order by rank_score desc, volume desc, transaction_count desc) as "Rank",user_address as "User Address",rank_score as "Score",transaction_count as "Transactions Count",round(volume, 2) as "Amount (in USD) of total transactions",cast(active_days_count as varchar) || ' / ' || cast(active_weeks_count as varchar) || ' / ' || cast(active_months_count as varchar) as "Unique Active Days/Weeks/Months",base_age_days as "Base Age in Days",initial_block_time as "Initial Active Date"from user_summary_with_rank