DataAngelbtc_eth_pre_post_halving_price
Updated 2024-08-08Copy 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
›
⌄
with eth as (
select *, to_char(hour, 'HH24:MI:SS') as time
from ethereum.price.ez_prices_hourly
where symbol='ETH' and name = 'ethereum'
order by hour
),
btc as (
select *, to_char(hour, 'HH24:MI:SS') as time
from bitcoin.price.ez_prices_hourly
where symbol='BTC' and name = 'bitcoin'
order by hour
),
combined_eth_btc as (
-- ETH data from 12.05.2019 to 07.08.2024
select hour as date, blockchain, symbol, price
from eth
where (hour between dateadd(year, -1, '2020-05-12 00:00:00') and current_date) and time = '00:00:00'
union
-- BTC data from 12.05.2019 to 07.08.2024
select hour as date, blockchain, symbol, price
from btc
where (hour between dateadd(year, -1, '2020-05-12 00:00:00') and current_date) and time = '00:00:00'
order by date
),
lagged_price as (
select *, lag(price) over (partition by symbol order by date) as prev_day_price
from combined_eth_btc
)
select *, round(coalesce(((price - prev_day_price) / prev_day_price) * 100, 0), 4) as percent_change_in_price
from lagged_price
order by symbol, date
QueryRunArchived: QueryRun has been archived