i_danWeekly Stats 2 copy
Updated 2025-02-26
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 new_wallets as (
SELECT
MIN(block_timestamp) as create_date
, origin_from_address
FROM kaia.defi.ez_dex_swaps
GROUP BY 2
),
last_week as (
SELECT
date_trunc('week', block_timestamp) as week_a
, SUM(CASE WHEN amount_in_usd IS NULL THEN amount_out_usd ELSE amount_in_usd END) as usd_volume_a
, COUNT(DISTINCT(tx_hash)) as tx_count_a
, COUNT(DISTINCT(origin_from_address)) as wallet_count_a
FROM kaia.defi.ez_dex_swaps
WHERE block_timestamp < date_trunc('week', current_date)
GROUP BY 1
ORDER BY 1 desc
),
previous_week as (
SELECT
date_trunc('week', block_timestamp) as week_b
, SUM(CASE WHEN amount_in_usd IS NULL THEN amount_out_usd ELSE amount_in_usd END) as usd_volume_b
, COUNT(DISTINCT(tx_hash)) as tx_count_b
, COUNT(DISTINCT(origin_from_address)) as wallet_count_b
FROM kaia.defi.ez_dex_swaps
WHERE block_timestamp < date_trunc('week', current_date)
GROUP BY 1
ORDER BY 1 desc
LIMIT 2
),
table_1 as (
SELECT *
FROM last_week
QueryRunArchived: QueryRun has been archived