kentovivacious-salmon
    Updated 2025-03-01
    WITH blockchain_data AS (
    -- Arbitrum
    SELECT
    'Arbitrum' AS blockchain,
    COUNT(*) AS total_transactions,
    MIN(BLOCK_TIMESTAMP) AS start_time,
    MAX(BLOCK_TIMESTAMP) AS end_time,
    SUM(TX_FEE) AS total_tx_fees,
    AVG(GAS_PRICE_BID) AS avg_gas_price,
    SUM(CASE WHEN TX_SUCCEEDED = TRUE THEN 1 ELSE 0 END) * 1.0 / COUNT(*) AS success_rate
    FROM
    arbitrum.core.fact_transactions
    WHERE
    BLOCK_TIMESTAMP >= '2023-02-01' AND BLOCK_TIMESTAMP < '2023-03-01'

    UNION ALL

    -- BSC
    SELECT
    'BSC' AS blockchain,
    COUNT(*) AS total_transactions,
    MIN(BLOCK_TIMESTAMP) AS start_time,
    MAX(BLOCK_TIMESTAMP) AS end_time,
    SUM(TX_FEE) AS total_tx_fees,
    AVG(GAS_PRICE) AS avg_gas_price,
    SUM(CASE WHEN TX_SUCCEEDED = TRUE THEN 1 ELSE 0 END) * 1.0 / COUNT(*) AS success_rate
    FROM
    bsc.core.fact_transactions
    WHERE
    BLOCK_TIMESTAMP >= '2023-02-01' AND BLOCK_TIMESTAMP < '2023-03-01'

    UNION ALL

    -- Ethereum
    SELECT
    'Ethereum' AS blockchain,
    QueryRunArchived: QueryRun has been archived