Afonso_Diazgas fee trends
    Updated 4 days ago
    WITH main AS (
    SELECT
    tx_hash,
    block_timestamp,
    tx_fee
    FROM kaia.core.fact_transactions
    ),
    daily_fees AS (
    SELECT
    DATE_TRUNC('month', block_timestamp) AS tx_day,
    COUNT(tx_hash) AS total_tx,
    SUM(tx_fee) AS total_fees,
    AVG(tx_fee) AS avg_fee_per_tx
    FROM main
    GROUP BY tx_day
    ),
    fee_trends AS (
    SELECT
    tx_day,
    total_tx,
    total_fees,
    avg_fee_per_tx,
    LAG(avg_fee_per_tx) OVER (ORDER BY tx_day) AS prev_avg_fee,
    (avg_fee_per_tx - LAG(avg_fee_per_tx) OVER (ORDER BY tx_day)) / NULLIF(LAG(avg_fee_per_tx) OVER (ORDER BY tx_day), 0) * 100 AS fee_change_pct
    FROM daily_fees
    )
    SELECT
    tx_day,
    total_tx,
    total_fees,
    avg_fee_per_tx,
    fee_change_pct
    FROM fee_trends
    ORDER BY tx_day
    Last run: 4 days ago
    TX_DAY
    TOTAL_TX
    TOTAL_FEES
    AVG_FEE_PER_TX
    FEE_CHANGE_PCT
    1
    2019-06-01 00:00:00.00013138.71200740.006635192232
    2
    2019-07-01 00:00:00.0002571511053.916705950.004098435184-38.23185462
    3
    2019-08-01 00:00:00.000627841369772.33339410.01111305252171.153550535
    4
    2019-09-01 00:00:00.000264467156616.2823556250.0214076844992.635501899
    5
    2019-10-01 00:00:00.000462776249596.72982260.01071721705-49.93752334
    6
    2019-11-01 00:00:00.00015344385107278.4019426770.006991378406-34.764982629
    7
    2019-12-01 00:00:00.0001009139149745.3491627750.00492948387-29.491960184
    8
    2020-01-01 00:00:00.0001290317353748.35139530.004165514281-15.49796307
    9
    2020-02-01 00:00:00.0001019955143664.21674060.004280994012.772280256
    10
    2020-03-01 00:00:00.000764786032392.432238250.004235489698-1.062938019
    11
    2020-04-01 00:00:00.000814370735597.96306570.0043712234573.20467689
    12
    2020-05-01 00:00:00.000492322820252.8736736250.004113738725-5.890450007
    13
    2020-06-01 00:00:00.000578791539725.4967979250.00686352456866.843959404
    14
    2020-07-01 00:00:00.000632554041588.5974221250.006574711001-4.207948326
    15
    2020-08-01 00:00:00.000641580627643.62340780.004308675076-34.465939626
    16
    2020-09-01 00:00:00.000557652519929.5846524250.003573835794-17.054878106
    17
    2020-10-01 00:00:00.000675434819222.116581050.002845887802-20.368814756
    18
    2020-11-01 00:00:00.000605580417693.3548663750.0029217185472.664572573
    19
    2020-12-01 00:00:00.000930964429744.16822290.0031949844949.352918221
    20
    2021-01-01 00:00:00.0001192010641726.03165090.0035004748839.561560921
    72
    6KB
    48s