mlhnear gas 5
    Updated 2022-07-23
    with contracts_fee as
    (SELECT BLOCK_TIMESTAMP, TX_RECEIVER, TRANSACTION_FEE/1e24 as fee, TX_HASH
    FROM near.core.fact_transactions
    )

    select *,
    sum(fees) over (partition by TX_RECEIVER order by date) as total_fees
    from
    (select *,
    row_number() over (partition by date order by fees desc) as rank
    from
    (select date_trunc('day',BLOCK_TIMESTAMP) as date, TX_RECEIVER, sum(fee) as fees, count(*) as total_txs
    from contracts_fee
    group by date, TX_RECEIVER))
    where rank<=5 and date_trunc('week',date)>=date_trunc('week',current_date)-- - INTERVAL '1 week'
    order by total_fees asc
    Run a query to Download Data