0xHaM-dUntitled Query
Updated 2022-09-06
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 DEPOSIT as (
SELECT
BLOCK_TIMESTAMP,
'DEPOSITOR' as status,
TX_HASH,
DEPOSITOR,
AMOUNT_DEPOSITED as amount
FROM ethereum.maker.ez_deposits
WHERE TX_STATUS = 'SUCCESS'
)
,WITHDRAW as (
SELECT
a.BLOCK_TIMESTAMP,
'WITHDRAWER' as status,
a.TX_HASH,
WITHDRAWER,
AMOUNT_WITHDRAWN as amount
FROM ethereum.maker.ez_withdrawals a join DEPOSIT b on WITHDRAWER = DEPOSITOR and a.BLOCK_TIMESTAMP > b.BLOCK_TIMESTAMP
)
SELECT
date_trunc('{{interval}}', block_timestamp) as date,
status,
COUNT(DISTINCT TX_HASH) as tx_cnt,
COUNT(DISTINCT DEPOSITOR) as user_cnt,
sum(tx_cnt) over (partition by status order by date) as cum_tx_cnt,
sum(user_cnt) over (partition by status order by date) as cum_user_cnt
from DEPOSIT
WHERE date >= '{{since_date}}'
group by 1,2
UNION
SELECT
date_trunc('{{interval}}', block_timestamp) as date,
status,
Run a query to Download Data