datavortexWeekly Volume Change Per Platform
Updated 2024-10-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
31
32
33
34
35
36
›
⌄
WITH WeeklyVolume AS (
SELECT
platform AS PlatformName,
DATE_TRUNC('week', block_timestamp) AS WeekStart,
SUM(amount_in_usd) AS TotalVolumeUSD
FROM
polygon.defi.ez_dex_swaps
WHERE
block_timestamp >= DATEADD(MONTH, -3, CURRENT_DATE)
GROUP BY
platform,
WeekStart
),
VolumeChange AS (
SELECT
PlatformName,
WeekStart,
TotalVolumeUSD,
LAG(TotalVolumeUSD) OVER (
PARTITION BY PlatformName
ORDER BY
WeekStart
) AS PrevWeekVolume
FROM
WeeklyVolume
)
SELECT
WeekStart AS Week,
PlatformName AS Platform,
TotalVolumeUSD AS CurrentWeekVolume,
PrevWeekVolume AS PreviousWeekVolume,
CASE
WHEN PrevWeekVolume IS NOT NULL
AND PrevWeekVolume != 0 THEN (
(TotalVolumeUSD - PrevWeekVolume) / PrevWeekVolume
) * 100
QueryRunArchived: QueryRun has been archived