MasiAverage Transactions, User, fee by old and new Users
Updated 2023-01-26Copy 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 tb1 as ( select min(block_timestamp) as days,
tx_sender
from terra.core.fact_transactions
group by 2)
,
tb2 as ( select DISTINCT tx_sender
from tb1
where days >= CURRENT_DATE - 30)
,
tb3 as ( select trunc(block_timestamp,'day') as day,
'New_users' as user_type,
count(DISTINCT tx_id) as count_tx,
count(DISTINCT tx_sender) as count_user,
sum(fee) as fee_amount_in_luna
from terra.core.fact_transactions
where block_timestamp >= CURRENT_DATE - 30
and tx_sender in (select tx_sender from tb2 )
group by 1,2
UNION
select trunc(block_timestamp,'day') as day,
'Old_users' as user_type,
count(DISTINCT tx_id) as count_tx,
count(DISTINCT tx_sender) as count_user,
sum(fee) as fee_amount_in_luna
from terra.core.fact_transactions
where block_timestamp >= CURRENT_DATE - 30
and tx_sender not in (select tx_sender from tb2 )
group by 1,2)
select case when day < '2023-01-14' then 'Pre-Station'
when day > '2023-01-14' then 'Post-Station'
when day = '2023-01-14' then 'Terra Station Launch' end as status,
user_type,
avg(count_tx) as average_tx,
avg(count_user) as average_user,
avg(fee_amount_in_luna) as average_fee
Run a query to Download Data