Query editor
WITH first_tx AS (-- Find the first transaction date for each user per chain (LIMITED TO LAST 1 MONTH)SELECTCAST("from" AS VARCHAR) AS wallet_address,MIN(block_date) AS first_tx_date,'ethereum' AS chainFROM ethereum.transactionsWHERE block_date >= DATE_ADD('month', -1, CURRENT_DATE)GROUP BY CAST("from" AS VARCHAR)UNION ALLSELECTCAST("from" AS VARCHAR) AS wallet_address,MIN(block_date) AS first_tx_date,'base' AS chainFROM base.transactionsWHERE block_date >= DATE_ADD('month', -1, CURRENT_DATE)GROUP BY CAST("from" AS VARCHAR)UNION ALLSELECTCAST("from" AS VARCHAR) AS wallet_address,MIN(block_date) AS first_tx_date,'arbitrum' AS chainFROM arbitrum.transactionsWHERE block_date >= DATE_ADD('month', -1, CURRENT_DATE)GROUP BY CAST("from" AS VARCHAR)UNION ALLSELECTCAST("from" AS VARCHAR) AS wallet_address,MIN(block_date) AS first_tx_date,'bnb' AS chainFROM bnb.transactionsWHERE block_date >= DATE_ADD('month', -1, CURRENT_DATE)GROUP BY CAST("from" AS VARCHAR)),retained_users AS (-- Calculate days since first transaction for each userSELECTt.chain,CAST(t."from" AS VARCHAR) AS wallet_address,f.first_tx_date,DATE_DIFF('day', f.first_tx_date, t.block_date) AS days_since_first_txFROM (SELECT "from", block_date, 'ethereum' AS chain FROM ethereum.transactionsUNION ALLSELECT "from", block_date, 'base' AS chain FROM base.transactionsUNION ALLSELECT "from", block_date, 'arbitrum' AS chain FROM arbitrum.transactionsUNION ALLSELECT "from", block_date, 'bnb' AS chain FROM bnb.transactions) tJOIN first_tx fON CAST(t."from" AS VARCHAR) = f.wallet_address AND t.chain = f.chainWHERE t.block_date >= DATE_ADD('month', -1, CURRENT_DATE) -- ✅ Apply date filter again