Ali3NNew vs Existing Traders Over Time (Kaiaswap Kaia)
Updated 2024-10-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
›
⌄
with timetable as (
select case when '{{TimeFrame}}' = 'Last 7 Days' then 7
when '{{TimeFrame}}' = 'Last 30 Days' then 30
when '{{TimeFrame}}' = 'Last 60 Days' then 60
when '{{TimeFrame}}' = 'Last 90 Days' then 90
when '{{TimeFrame}}' = 'Last 180 Days' then 180
when '{{TimeFrame}}' = 'Last 365 Days' then 365
when '{{TimeFrame}}' = 'All Time' then 5000
else 5000 end as timeframe),
maintable as (
select block_timestamp,
platform,
tx_hash,
origin_from_address,
amount_in_usd,
row_number () over (partition by origin_from_address order by block_timestamp asc) as rn
from kaia.defi.ez_dex_swaps
where platform ilike '%kaiaswap%')
select date_Trunc ({{Date_Trunc}},block_timestamp) as date,
case when rn = 1 then 'New Traders' else 'Existing Traders' end as type,
count (distinct tx_hash) as Swaps_Count,
count (distinct origin_from_address) as Traders_Count
from maintable t1 join timetable
where block_timestamp >= current_date - timeframe
group by 1,2
order by 1 desc
QueryRunArchived: QueryRun has been archived