Updated 2024-12-09
    WITH total_seconds AS (
    SELECT
    366 * 24 * 60 * 60 AS total_seconds_in_2024
    ),
    BNBPrice AS (
    SELECT
    AVG(price) AS bnb_price
    FROM
    bsc.price.ez_prices_hourly
    WHERE
    symbol = 'BNB'
    ),
    transaction_metrics AS (
    SELECT
    COUNT(DISTINCT tx_hash) AS total_transactions,
    COUNT(DISTINCT from_address) AS active_users,
    SUM(tx_fee) AS total_gas_in_bnb,
    AVG(tx_fee) AS avg_transaction_fee_in_bnb,
    COUNT(DISTINCT tx_hash) / (
    SELECT
    total_seconds_in_2024
    FROM
    total_seconds
    ) AS avg_transactions_per_second,
    SUM(tx_fee) / COUNT(DISTINCT tx_hash) AS avg_gas_fee_per_transaction_in_bnb,
    SUM(tx_fee) / COUNT(DISTINCT from_address) AS avg_gas_spent_per_user_in_bnb
    FROM
    bsc.core.fact_transactions
    WHERE
    block_timestamp >= '2024-01-01'
    AND block_timestamp <= '2024-12-31'
    AND status = 'SUCCESS'
    ),
    gas_conversion AS (
    SELECT
    tm.total_transactions,
    QueryRunArchived: QueryRun has been archived