Query editor
WITH mint_events AS (SELECT"to" AS borrower,date_trunc('month', block_time) AS mint_monthFROM tokens.transfersWHERE blockchain = 'hyperevm'AND contract_address = 0xca79db4b49f608ef54a5cb813fbed3a6387bc645AND "from" = 0x0000000000000000000000000000000000000000AND block_date >= DATE '2025-01-01'),first_mint AS (SELECT borrower, MIN(mint_month) AS cohort_monthFROM mint_eventsGROUP BY 1),cohort_activity AS (SELECTf.cohort_month,m.mint_month,DATE_DIFF('month', f.cohort_month, m.mint_month) AS months_since_first,COUNT(DISTINCT m.borrower) AS active_borrowersFROM mint_events mJOIN first_mint f ON m.borrower = f.borrowerGROUP BY 1, 2, 3)SELECTcohort_month,DATE_FORMAT(cohort_month, '%Y-%m') AS cohort_label,months_since_first,active_borrowers,FIRST_VALUE(active_borrowers) OVER (PARTITION BY cohort_month ORDER BY months_since_first) AS cohort_size,ROUND(active_borrowers * 100.0 /FIRST_VALUE(active_borrowers) OVER (PARTITION BY cohort_month ORDER BY months_since_first), 1) AS retention_pct,ROUND(active_borrowers * 1.0 /FIRST_VALUE(active_borrowers) OVER (PARTITION BY cohort_month ORDER BY months_since_first), 4) AS retention_decimalFROM cohort_activityWHERE months_since_first <= 6ORDER BY cohort_month DESC, months_since_first