Query editor
WITH base_table AS (SELECTDATE_TRUNC('week', block_time) AS week,trader_id AS addressFROM dex_solana.tradeswheretoken_bought_mint_address like '{{token_address}}'GROUP BY1,2), user_cohorts AS (SELECTaddress,DATE_TRUNC('week', MIN(week)) AS cohort_weekFROM base_tableGROUP BYaddress), cohort_size AS (SELECTcohort_week,COUNT(DISTINCT address) AS first_users_countFROM user_cohortsGROUP BYcohort_week), following_weeks AS (SELECTbt.address,(EXTRACT(DOY FROM bt.week) - EXTRACT(DOY FROM uc.cohort_week)) / 7 AS week_numberFROM base_table AS btINNER JOIN user_cohorts AS ucON bt.address = uc.addressWHEREbt.week > uc.cohort_weekGROUP BY1,2), retention_data AS (SELECTuc.cohort_week AS cohort_week,fm.week_number,COUNT(DISTINCT fm.address) AS retained_users_countFROM following_weeks AS fmINNER JOIN user_cohorts AS ucON fm.address = uc.addressGROUP BYuc.cohort_week,fm.week_number), retention_table_long AS (SELECTr.cohort_week,r.week_number,c.first_users_count,r.retained_users_count,round((cast(r.retained_users_count as double)*1.0) / cast(c.first_users_count as double),3) as ratioFROM retention_data AS rINNER JOIN cohort_size AS cON r.cohort_week = c.cohort_weekWHERE