kellenEthereum Retention Cohorts
    Updated 2022-12-21

    WITH t0 AS (
    SELECT DATE_TRUNC('month', block_timestamp) AS month
    , from_address AS address
    , 'Ethereum' AS chain
    FROM ethereum.core.fact_transactions
    WHERE block_timestamp >= '2021-01-01'
    GROUP BY 1, 2, 3
    ), t1 AS (
    SELECT address
    , chain
    , MIN(month) AS first_month
    FROM t0
    GROUP BY 1, 2
    ), t2 AS (
    SELECT t0.chain
    , t1.first_month
    , COUNT(1) AS base_addresses
    FROM t0
    JOIN t1 ON t1.address = t0.address
    AND t1.chain = t0.chain
    AND t1.first_month = t0.month
    GROUP BY 1, 2
    ), t3 AS (
    SELECT t2.first_month
    , t2.base_addresses
    , t0.month
    , t0.chain
    , COUNT(1) AS n_active_addresses
    FROM t0
    JOIN t1 ON t1.address = t0.address
    AND t1.chain = t0.chain
    JOIN t2 ON t2.chain = t0.chain
    AND t2.first_month = t1.first_month
    GROUP BY 1, 2, 3, 4
    )
    Run a query to Download Data