cristinatintobitcoin 7
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
›
⌄
-- Calculate average number of transactions per block and miner rewards per month
WITH transactions_per_block AS (
SELECT
DATE_TRUNC('MONTH', BLOCK_TIMESTAMP) AS MONTH,
BLOCK_NUMBER,
avg(tx_count) AS NUM_TRANSACTIONS
FROM bitcoin.core.fact_blocks
GROUP BY MONTH, BLOCK_NUMBER
),
miner_rewards AS (
SELECT
DATE_TRUNC('MONTH', BLOCK_TIMESTAMP) AS MONTH,
BLOCK_NUMBER,
AVG(TOTAL_REWARD) AS AVERAGE_REWARD
FROM bitcoin.core.ez_miner_rewards
GROUP BY MONTH, BLOCK_NUMBER
)
SELECT
t.MONTH,
AVG(NUM_TRANSACTIONS) AS AVERAGE_TRANSACTIONS_PER_BLOCK,
AVG(AVERAGE_REWARD) AS AVERAGE_MINER_REWARD
FROM transactions_per_block t
JOIN miner_rewards m
ON t.MONTH = m.MONTH AND t.BLOCK_NUMBER = m.BLOCK_NUMBER
GROUP BY t.MONTH
ORDER BY t.MONTH
Run a query to Download Data