Crazzy_SidAptos: Total Number of Addresses with a Non-Zero Balance
Updated 2024-10-13
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 balance_calculations AS (
SELECT
ADDRESS,
SUM(CASE WHEN TYPE = 'IN' THEN AMOUNT ELSE -AMOUNT END) AS balance
FROM (
SELECT
TO_ADDRESS AS ADDRESS,
AMOUNT,
'IN' AS TYPE
FROM
aptos.core.ez_native_transfers
WHERE
SUCCESS = TRUE
AND BLOCK_TIMESTAMP >= DATEADD(day, -30, CURRENT_TIMESTAMP())
UNION ALL
SELECT
FROM_ADDRESS AS ADDRESS,
AMOUNT,
'OUT' AS TYPE
FROM
aptos.core.ez_native_transfers
WHERE
SUCCESS = TRUE
AND BLOCK_TIMESTAMP >= DATEADD(day, -30, CURRENT_TIMESTAMP())
) AS combined_transfers
GROUP BY
ADDRESS
)
SELECT
COUNT(DISTINCT ADDRESS) AS total_non_zero_balance_addresses
FROM
balance_calculations
WHERE
balance <> 0;
QueryRunArchived: QueryRun has been archived