datavortexTotal Users And Swaps
Updated 2024-11-18
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
›
⌄
WITH weekly_data AS (
SELECT
DATE_TRUNC('week', block_timestamp) AS week,
COUNT(DISTINCT tx_hash) AS total_swaps,
SUM(amount_in_usd) AS total_volume,
COUNT(DISTINCT trader) AS unique_users
FROM near.defi.ez_dex_swaps
WHERE block_timestamp BETWEEN '2024-01-01' AND '2024-12-31'
GROUP BY DATE_TRUNC('week', block_timestamp)
),
cumulative_data AS (
SELECT
week,
total_swaps,
total_volume,
unique_users,
SUM(total_swaps) OVER (ORDER BY week) AS cumulative_swaps,
SUM(total_volume) OVER (ORDER BY week) AS cumulative_volume,
SUM(unique_users) OVER (ORDER BY week) AS cumulative_users
FROM weekly_data
)
SELECT *
FROM cumulative_data
ORDER BY week;
QueryRunArchived: QueryRun has been archived