OneDataAnalystMAKER - Merge
Updated 2022-09-25Copy 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 t1 AS (
SELECT Date_trunc('day',BLOCK_TIMESTAMP) AS Date,
SUM(AMOUNT_DEPOSITED) AS Deposit_vol,
COUNT(DISTINCT DEPOSITOR) AS Depositors
FROM ethereum.maker.ez_deposits
WHERE SYMBOL IN ('ETH','WETH','stETH','rETH','aETH')
AND date >= CURRENT_DATE - 60
AND Date < Current_date
GROUP BY 1
),
t2 AS (
SELECT Date_trunc('day',BLOCK_TIMESTAMP) AS Dt,
SUM(AMOUNT_WITHDRAWN) AS withdrawn_vol,
COUNT(DISTINCT WITHDRAWER) AS Withdrawers
FROM ethereum.maker.ez_withdrawals
WHERE SYMBOL IN ('ETH','WETH','stETH','rETH','aETH')
AND dt >= CURRENT_DATE - 60
AND dt < Current_date
GROUP BY 1
)
SELECT Date,
Deposit_vol,withdrawn_vol,
Depositors,Withdrawers,
Deposit_vol-withdrawn_vol AS Deposit_withdraw_balance,
Depositors-Withdrawers AS Depositors_Balance,
IFF(date = '2022-09-15', 'Merge-Day', IFF(date < '2022-09-15','Pre-Merge','Post-Merge')) AS Merge_status,
AVG(Deposit_vol) OVER (Partition BY Merge_status) AS AVG_Deposit_vol,
AVG(withdrawn_vol) OVER (Partition BY Merge_status) AS AVG_withdrawn_vol,
AVG(Depositors) OVER (Partition BY Merge_status) AS AVG_Depositors,
AVG(Withdrawers) OVER (Partition BY Merge_status) AS AVG_Withdrawers,
AVG(Deposit_withdraw_balance) OVER (Partition BY Merge_status) AS AVG_Deposit_withdraw_balance,
AVG(Depositors_Balance) OVER (Partition BY Merge_status) AS AVG_Depositors_Balance
Run a query to Download Data