Kruys-Collins Daily and Running Average GAs Usage copy
    Updated 2025-05-07
    -- forked from Daily and Running Average GAs Usage @ https://flipsidecrypto.xyz/studio/queries/4120830a-778f-4b81-b8da-fc8399b73c84

    WITH DailyGas AS (
    SELECT
    DATE(block_timestamp) AS transaction_date,
    SUM(gas_used/1e6 * gas_unit_price) as gas_fee
    FROM movement.core.fact_transactions
    WHERE tx_type = 'user_transaction'
    AND block_timestamp > '2025-01-01'
    GROUP BY transaction_date
    ),
    RunningCumulative AS (
    SELECT
    transaction_date,
    gas_fee,
    SUM(gas_fee) OVER (ORDER BY transaction_date) AS cumulative_gas_used
    FROM DailyGas
    )
    SELECT
    transaction_date as "Transaction Date",
    gas_fee AS "Daily Gas Used",
    cumulative_gas_used / ROW_NUMBER() OVER (ORDER BY transaction_date) AS "Daily Avg. Running Total"
    FROM RunningCumulative
    ORDER BY "Transaction Date";


    Last run: 2 months ago
    Transaction Date
    Daily Gas Used
    Daily Avg. Running Total
    1
    2025-01-01 00:00:00.0000.0120.012
    2
    2025-01-02 00:00:00.0000.01150.01175
    3
    2025-01-03 00:00:00.0000.0120.011833333333
    4
    2025-01-04 00:00:00.0000.0120.011875
    5
    2025-01-05 00:00:00.0000.0120.0119
    6
    2025-01-06 00:00:00.0000.0110.01175
    7
    2025-01-07 00:00:00.0000.1250.027928571429
    8
    2025-01-08 00:00:00.0000.01690.02655
    9
    2025-01-09 00:00:00.0000.0120.024933333333
    10
    2025-01-10 00:00:00.0000.0120.02364
    11
    2025-01-11 00:00:00.0000.0120.022581818182
    12
    2025-01-12 00:00:00.0000.0120.0217
    13
    2025-01-13 00:00:00.0000.0120.020953846154
    14
    2025-01-14 00:00:00.0000.01150.020278571429
    15
    2025-01-15 00:00:00.0000.00980.01958
    16
    2025-01-16 00:00:00.0000.03580.02059375
    17
    2025-01-17 00:00:00.0000.0120.020088235294
    18
    2025-01-18 00:00:00.0000.0120.019638888889
    19
    2025-01-19 00:00:00.0000.0110.019184210526
    20
    2025-01-20 00:00:00.0000.0120.018825
    ...
    108
    6KB
    20s