maybeyonasnear_gas_weekly_top10
    Updated 2022-07-25
    with
    tx_details as (
    select
    block_timestamp,
    txn_hash,
    tx_receiver,
    tx_signer,
    gas_used/pow(10,9) as giga_gas,
    transaction_fee/pow(10,24) as tx_fee
    from mdao_near.transactions
    )

    select * from (
    select
    last_day(block_timestamp,'week') as date,
    tx_receiver as contract,
    sum(giga_gas) as gas_total,
    sum(tx_fee) as fee_total,
    count(distinct txn_hash) as txs,
    fee_total/txs as fee_per_tx,
    rank() over(partition by date order by gas_total desc) as rank
    -- count(distinct tx_signer) as users
    from tx_details
    group by 1,2
    order by gas_total desc
    )
    where rank <= 10
    and date >= '2022-04-01'
    -- limit 10
    Run a query to Download Data