germanLast 7 days most gas on to use (bars)
    Updated 2022-08-06
    /*What contracts are users spending the most gas on to use?
    How has this changed over the past week? Past month?
    The gas units in the table are in raw (not decimal adjusted) format. To adjust accordingly, divide by 10^12.*/

    with last_week as (
    SELECT
    block_timestamp::date as day,
    tx_receiver as protocols,
    sum(gas_used) /POW(10,12) as gas_spent,
    RANK() OVER (partition by day order by gas_spent DESC ) as rank
    FROM near.core.fact_transactions
    WHERE block_timestamp > current_date - 7
    GROUP BY 1,2 )

    SELECT day,
    protocols,
    gas_spent
    FROM last_week
    WHERE rank <= 5
    order by DAY
    Run a query to Download Data