kiwiengoBitcoin Hash Rate & Difficulty - Halving
    Updated 2024-10-14
    -- forked from Ario / Bitcoin Hash Rate & Difficulty - Halving @ https://flipsidecrypto.xyz/Ario/q/3pTHBySQRjG2/bitcoin-hash-rate-difficulty---halving

    -- forked from Bitcoin Hash Rate & Difficulty @ https://flipsidecrypto.xyz/edit/queries/a5c72e4c-d7a9-42c4-9f89-6be0bf29c48b

    SELECT
    DATE_TRUNC('week', BLOCK_TIMESTAMP) AS week,
    AVG(difficulty) AS avg_difficulty,
    AVG(CAST(difficulty AS DOUBLE) * (interval / 600)) / POWER(10, 11) AS hash_rate
    FROM
    (
    SELECT
    BLOCK_TIMESTAMP,
    difficulty,
    DATEDIFF(
    'SECOND',
    LAG(BLOCK_TIMESTAMP, 1) OVER (
    ORDER BY
    BLOCK_TIMESTAMP
    ),
    BLOCK_TIMESTAMP
    ) AS interval
    FROM
    bitcoin.core.fact_blocks
    )
    where BLOCK_TIMESTAMP::date >= '2020-05-11'
    GROUP BY
    1
    ORDER BY
    1 DESC


    QueryRunArchived: QueryRun has been archived