sunshine-juliaATR 14
Updated 2022-12-03Copy 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
›
⌄
with tab1 as (select block_timestamp::date as date, receiver, amount/pow (10,decimal) as Receive_Volume
from axelar.core.fact_transfers
where currency = 'uaxl'
and transfer_type in ('AXELAR','IBC_TRANSFER_IN')),
tab2 as (
select block_timestamp::date as date, sender, amount/pow (10,decimal) as Send_Volume
from axelar.core.fact_transfers
where currency = 'uaxl'
and transfer_type in ('AXELAR','IBC_TRANSFER_OUT')),
tab3 as (
select tab1.date,
receiver as AXL_Holder,
sum (Send_Volume) as Daily_Send_Volume,
sum (Receive_Volume) as Daily_Receive_Volume
from tab1 join tab2 on tab1.Date = tab2.Date and Receiver = Sender
group by 1,2),
final_tab as (select date, AXL_Holder,
ifnull (Daily_Receive_Volume, 0) as Daily_Receive_Volumes,
ifnull (Daily_Send_Volume, 0) as Daily_Send_Volumes,
Daily_Receive_Volumes - Daily_Send_Volumes as NET_AXL_Balance,
sum (NET_AXL_Balance) over (partition by AXL_Holder order by date) as Balance
from tab3)
select date, Balance
from final_tab where date >= current_date - 30
Run a query to Download Data