Query editor
WITH first_tx AS (-- Find the first transaction date for each user (LIMITED TO LAST 1 MONTH)SELECTCAST("from" AS VARCHAR) AS wallet_address,MIN(block_date) AS first_tx_dateFROM ethereum.transactionsWHERE block_date >= DATE_ADD('month', -3, CURRENT_DATE) -- ✅ Only last 1 monthGROUP BY CAST("from" AS VARCHAR)),retained_users AS (-- Calculate days since first transaction for each userSELECTCAST(t."from" AS VARCHAR) AS wallet_address, -- ✅ Ensure consistencyf.first_tx_date,DATE_DIFF('day', f.first_tx_date, t.block_date) AS days_since_first_txFROM ethereum.transactions tJOIN first_tx f ON CAST(t."from" AS VARCHAR) = f.wallet_addressWHERE t.block_date >= DATE_ADD('month', -3, CURRENT_DATE) -- ✅ Apply date filter again),retention_counts AS (-- Count unique users at 0, 30 daysSELECTCOUNT(DISTINCT CASE WHEN days_since_first_tx = 0 THEN wallet_address END) AS users_day_0,COUNT(DISTINCT CASE WHEN days_since_first_tx >= 30 THEN wallet_address END) AS users_day_30FROM retained_users)-- ✅ Calculate Retention Rate (Only 30-Day Retention for Speed)SELECTusers_day_0,users_day_30,ROUND((users_day_30 * 100.0 / NULLIF(users_day_0, 0)), 2) AS retention_30dFROM retention_counts;