Query editor
with all_contracts as (select address from ethereum.creation_traces), relevant_transactions as (select *, row_number() over (partition by month order by gas desc) as ranks from (select to as contract_address, date_trunc('month', block_time) as month, SUM((CAST(gas_used as uint256) * gas_price)/pow(10, 18)) as gas from ethereum.transactions tleft join all_contracts c on c.address = t.towhere c.address is not null and date_trunc('month', block_time) > DATE '2020-01-01'-- For now, work with Aug 2023=group by 1, 2)), total_gas as (select SUM(gas) as total, month from relevant_transactionsgroup by 2)-- , name_to_narrative as (-- select-- ), final as (select cat, gas, f.month from (select contract_address, gas, r.month, t.total from relevant_transactions rleft join total_gas t on t.month = r.monthwhere ranks <= 50) as fleft join dune.kingyo.result_categories l on l.addr = f.contract_address),monthly_sum as (select sum(gas) as monthly_total, month from finalgroup by 2),final_cat_sum as ((select sum(gas) as cat_total, cat, month from finalgroup by cat, month))select cat_total, cat, s.month , (cat_total/ monthly_total) * 100 as share from final_cat_sum sleft join monthly_sum m on m.month = s.month-- select sum()-- , actual_monthly_sum as (-- select sum(gas) as gas, month from final-- group by 2-- )-- , temp as (select contract_address, l.category , created_at, row_number() over (partition by contract_address order by created_at asc) as "rank", model_name, contributor from (select distinct contract_address from final where category is null) f-- left join labels.addresses l on l.address = f.contract_address and l.blockchain = 'ethereum'-- where l.category is not null and model_name not in ('contracts', 'dex_trader'))-- select contract_address , max(gas) from final where cat is null-- group by 1-- order by 2 desc