khanhUntitled Query
Updated 2022-09-23
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
list1 as (
select hour::date day,
avg(price) as price
from ethereum.core.fact_hourly_token_prices
where token_address = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'
group by day
),
list2 as (
select block_timestamp::date day,
sum(event_inputs:amount / pow(10, 18)) as total_amount,
count(distinct (tx_hash)) as tx_num
from ethereum.core.fact_event_logs
where contract_address = origin_to_address
and origin_to_address = '0x4da27a545c0c5b758a6ba100e3a049001de870f5'
and event_name = 'Redeem'
group by day
),
list3 as (
select day,
total_amount,
total_amount * price as amount_usd,
tx_num,
price
from list2
left join list1
using(day)
)
select
sum(total_amount) as total_amount,
sum(total_amount * price) as total_amount_usd,
sum(tx_num) as tx_num
Run a query to Download Data