kiwiengoBitcoin Hash Rate & Difficulty - Halving copy
Updated 2024-02-28Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
-- 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
with price as (
select DATE_TRUNC('week', timestamp) AS week,
AVG(price) AS avg_price
from
(
SELECT
hour as timestamp,
price
FROM
bitcoin.price.ez_hourly_token_prices
)
where timestamp >= '2010-05-11'
GROUP BY
1
ORDER BY
1 DESC
),
hashrate as (
SELECT
DATE_TRUNC('week', BLOCK_TIMESTAMP) AS week,
AVG(difficulty) AS avg_difficulty,
AVG(CAST(difficulty AS DOUBLE) * POWER(2,32)* (1/600.0)) / POWER(10,18) AS hash_rate
FROM
(
SELECT
BLOCK_TIMESTAMP,
difficulty,
DATEDIFF(
'SECOND',
LAG(BLOCK_TIMESTAMP, 1) OVER (
ORDER BY
BLOCK_TIMESTAMP
QueryRunArchived: QueryRun has been archived