Query editor
WITH first_tx AS (SELECTsender,DATE_TRUNC('month', MIN(date)) AS first_monthFROM sui.transactionsWHERE execution_success = trueGROUP BY sender),monthly_users AS (SELECTDATE_TRUNC('month', t.date) AS month,COUNT(DISTINCT t.sender) AS active_users,COUNT(DISTINCT CASEWHEN f.first_month = DATE_TRUNC('month', t.date)THEN t.senderEND) AS new_usersFROM sui.transactions tJOIN first_tx fON t.sender = f.senderWHERE execution_success = trueGROUP BY 1)SELECTmonth,active_users,new_users,active_users - new_users AS returning_users,(active_users - new_users) * 1.0 / active_users AS returning_ratioFROM monthly_usersORDER BY month;