sarah_ehinsNew VS Returning
    Updated 2025-04-01
    --Identify new vs. returning users each week.
    WITH first_time_users AS (
    SELECT
    FROM_ADDRESS AS sender,
    MIN(BLOCK_TIMESTAMP) AS first_tx_date
    FROM base.core.fact_transactions
    GROUP BY FROM_ADDRESS
    )
    SELECT
    DATE_TRUNC('week', t.BLOCK_TIMESTAMP) AS week,
    COUNT(DISTINCT CASE WHEN DATE_TRUNC('day', t.BLOCK_TIMESTAMP) = DATE_TRUNC('day', f.first_tx_date) THEN t.FROM_ADDRESS END) AS new_users,
    COUNT(DISTINCT CASE WHEN DATE_TRUNC('day', t.BLOCK_TIMESTAMP) > DATE_TRUNC('day', f.first_tx_date) THEN t.FROM_ADDRESS END) AS returning_users
    FROM base.core.fact_transactions t
    LEFT JOIN first_time_users f ON t.FROM_ADDRESS = f.sender
    GROUP BY week
    ORDER BY week;
    Last run: about 2 months ago
    WEEK
    NEW_USERS
    RETURNING_USERS
    1
    2023-06-12 00:00:00.000102
    2
    2023-06-19 00:00:00.00034
    3
    2023-06-26 00:00:00.000116
    4
    2023-07-03 00:00:00.00045
    5
    2023-07-10 00:00:00.000350131373
    6
    2023-07-17 00:00:00.000314247149
    7
    2023-07-24 00:00:00.0005742811255
    8
    2023-07-31 00:00:00.000190153116904
    9
    2023-08-07 00:00:00.000241501215293
    10
    2023-08-14 00:00:00.000179044224407
    11
    2023-08-21 00:00:00.000208268275164
    12
    2023-08-28 00:00:00.000105087220725
    13
    2023-09-04 00:00:00.00071603196803
    14
    2023-09-11 00:00:00.000116296190026
    15
    2023-09-18 00:00:00.000119289198372
    16
    2023-09-25 00:00:00.000144458201248
    17
    2023-10-02 00:00:00.000126193204733
    18
    2023-10-09 00:00:00.000242650194160
    19
    2023-10-16 00:00:00.000335798212753
    20
    2023-10-23 00:00:00.000124244224229
    97
    4KB
    432s