Sardius-0626BOOP New and Returning Traders by Week
Updated 2024-08-20
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
›
⌄
WITH Weekly_Trader_Activity AS (
SELECT
origin_from_address,
MIN(DATE_TRUNC('week', block_timestamp)) AS first_trade_week,
COUNT(*) AS total_trades,
COUNT(DISTINCT DATE_TRUNC('week', block_timestamp)) AS active_weeks,
FROM arbitrum.defi.ez_dex_swaps
WHERE token_in=LOWER('0x13A7DeDb7169a17bE92B0E3C7C2315B46f4772B3')
OR token_out=LOWER('0x13A7DeDb7169a17bE92B0E3C7C2315B46f4772B3')
GROUP BY origin_from_address
),
Trader_Status AS (
SELECT
*,
CASE
WHEN active_weeks = 1 THEN 'New Trader'
ELSE 'Returning Trader'
END AS trader_status
FROM Weekly_Trader_Activity
)
SELECT
first_trade_week,
trader_status,
COUNT(*) AS number_of_traders,
AVG(total_trades) AS average_trades_per_trader,
AVG(active_weeks) AS average_active_weeks
FROM Trader_Status
GROUP BY first_trade_week, trader_status
ORDER BY first_trade_week, trader_status;
QueryRunArchived: QueryRun has been archived