Query editor
with data as (select *from (select case when to = 0x6CA2A628fb690Bd431F4aA608655ce37c66aff9d then 'reya'when to = 0x51C4a227D59E49E26Ea07D8e4E9Af163da4c87A0 then 'real'when to = 0xf75206c49c1694594e3e69252e519434f1579876 then 'alephzero'when to = 0xf4ef823d57819ac7202a081a5b49376bd28e7b3a then 'kinto'when to = 0x8d99372612e8cfe7163b1a453831bc40eaeb3cf3 then 'gravity'when to = 0xb7d188eb30e7984f93bec34ee8b45a148bd594c6 then 'alienx'else 'others'end as flag, to, bytearray_substring(data,1,4) as methodid, date_trunc('month',block_date) as mth, date_trunc('year',block_date) as yr, count(distinct block_date) as no_days, sum(gas_price*gas_used/power(10,18)) as total_tx_fee_eth, sum(gas_price*gas_used/power(10,18)*price) as total_tx_fee_usd, avg(gas_price*gas_used/power(10,18)) as avg_tx_fee_eth, avg(gas_price*gas_used/power(10,18)*price) as avg_tx_fee_usd, approx_percentile(gas_price*gas_used/power(10,18),0.5) as median_tx_fee_eth, approx_percentile(price*gas_price*gas_used/power(10,18),0.5) as median_tx_fee_usd, count(distinct hash) as tx_hash, count(distinct "from") as from_address_cnt,min(block_number) as min_block_numberfrom ethereum.transactions tleft join prices.usd_latest p on blockchain='arbitrum' and contract_address=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 --weth price on arb onewhere bytearray_substring(data,1,4) in ( 0x8f111f3c , 0x3e5aa082, 0xe0bc9729)and date_trunc('day',block_time) >= timestamp '2023-10-01'group by 1,2 , 3 ,4,5order by total_tx_fee_eth desc)where flag !='others')select *, sum(total_tx_fee_eth) over(partition by flag order by mth) as total_feerollingfrom dataorder by flag asc, mth desc--select *--from prices.usd_latest where contract_address=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1--and hash=0x752927240acecbc22e280fa94be2cf73d6dd979ab214b8771ab7ef60359873e4