Query editor
WITH reputation_filtered_users AS (SELECT_0 AS address,MAX(output_reputationPoints) AS reputation_pointsFROM p2px_polygon.ReputationManager_call_rmusersGROUP BY _0HAVING MAX(output_reputationPoints) > 100),base_table AS (SELECTDATE_TRUNC('week', evt_block_time) AS week,user AS addressFROM p2px_polygon.BrokerFactoryv2_evt_OrderPlacedWHERE user IN (SELECT address FROM reputation_filtered_users)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,