Query editor
-- AX1 | Base Agentic — Agent Retention & Cohort Analysis-- Simplified cohort retention using monthly cohorts for performanceWITH user_first_touch AS (SELECTt."from" AS user_address,MIN(DATE_TRUNC('month', t.block_time)) AS cohort_monthFROM base.transactions tWHERE t.block_time >= TIMESTAMP '2024-09-01'AND t.block_time < NOW()AND t.success = TRUEAND t.to IN (0x1bb0b3bc29e03dab0eed2b14a8b2d61fa3ee7e16,0x5d64d14d2cf4fe5db89cd71fb9b6e24cc65e7347,0x7e7a0e201fd38d3adaa9523da6c109a07118c96a,0x09188484e1ab980daef1b89c673a87f89fca674a,0x0b0d3fdb861b4c2827c8c97ec84a6d1a44f05a55,0x940181a94a35a4569e4529a3cdfb74e38fd98631,0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22)GROUP BY 1),user_monthly_activity AS (SELECT DISTINCTt."from" AS user_address,DATE_TRUNC('month', t.block_time) AS activity_monthFROM base.transactions tWHERE t.block_time >= TIMESTAMP '2024-09-01'AND t.block_time < NOW()AND t.success = TRUEAND t.to IN (0x1bb0b3bc29e03dab0eed2b14a8b2d61fa3ee7e16,0x5d64d14d2cf4fe5db89cd71fb9b6e24cc65e7347,0x7e7a0e201fd38d3adaa9523da6c109a07118c96a,0x09188484e1ab980daef1b89c673a87f89fca674a,0x0b0d3fdb861b4c2827c8c97ec84a6d1a44f05a55,0x940181a94a35a4569e4529a3cdfb74e38fd98631,0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22)),cohort_sizes AS (SELECT cohort_month, COUNT(DISTINCT user_address) AS cohort_sizeFROM user_first_touchGROUP BY 1),retention AS (SELECTuft.cohort_month,uma.activity_month,DATE_DIFF('month', uft.cohort_month, uma.activity_month) AS months_since_join,COUNT(DISTINCT uft.user_address) AS retained_usersFROM user_first_touch uftINNER JOIN user_monthly_activity uma ON uft.user_address = uma.user_addressWHERE uma.activity_month >= uft.cohort_monthGROUP BY 1, 2, 3)