mz0111Segmentation 9
Updated 2023-03-16
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 tab1 as (select
signer_id,
min(a.block_timestamp) as min_time
from near.social.fact_addkey_events a
join near.core.fact_transactions b on a.tx_hash = b.tx_hash
where tx_status = 'Success'
group by 1
having min_time BETWEEN '{{first_date}}' and '{{last_date}}'
),
tab2 as (
SELECT
date_trunc('day', timestamp) as day,
symbol,
avg(price_usd) as usd_price
FROM near.core.fact_prices
GROUP BY 1,2),
tab3 as (
SELECT
distinct(TRADER) as user,
BLOCK_TIMESTAMP:: date as day,
count (distinct TX_HASH) as TXS,
TOKEN_out,
sum(AMOUNT_out*usd_price) as usd_vol
from near.core.ez_dex_swaps
join tab2 on symbol= TOKEN_out
where day >= current_date - {{period}}
group by 1 , 2 , 4
)
SELECT
day,
TXS,
usd_vol,
TOKEN_out,
Run a query to Download Data