SELECT
COUNT(DISTINCT address) AS total_active_addresses
FROM
(
SELECT FROM_ADDRESS AS address
FROM aptos.core.ez_native_transfers
WHERE BLOCK_TIMESTAMP >= DATEADD(day, -30, CURRENT_TIMESTAMP())
AND SUCCESS = TRUE
UNION
SELECT TO_ADDRESS AS address
FROM aptos.core.ez_native_transfers
WHERE BLOCK_TIMESTAMP >= DATEADD(day, -30, CURRENT_TIMESTAMP())
AND SUCCESS = TRUE
) AS active_addresses;