PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Analytics & Experimentation/Intuit

Build 30-day retention cohort table

Last updated: Mar 29, 2026

Quick Overview

This question evaluates SQL-based cohort analysis, 30-day retention metric calculation, handling of right-censoring, and data-quality reasoning within the Analytics & Experimentation domain for a Data Scientist role, emphasizing practical application of SQL and time-windowed data wrangling.

  • medium
  • Intuit
  • Analytics & Experimentation
  • Data Scientist

Build 30-day retention cohort table

Company: Intuit

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: medium

Interview Round: Technical Screen

Using the same schema, produce a monthly cohort table of 30-day retention based on signupdate. For each cohort_month = date_trunc('month', signupdate), compute cohort_size, d30_retained, and d30_retention_rate = d30_retained/cohort_size. A company is considered retained at day 30 if terminationdate is NULL or terminationdate >= signupdate + INTERVAL '30 days' (i.e., churn strictly before day 30 is not retained; churn on day 30 counts as retained). Handle right-censoring by excluding signups where signupdate + INTERVAL '30 days' > as_of_date. Use as_of_date = '2025-09-01'. Return: cohort_month (DATE, first day of month), cohort_size (INT), d30_retained (INT), d30_retention_rate (NUMERIC, 3 decimals). Do not exclude Free_Subs in this metric unless you add a separate column showing paid-only retention. Schema and small sample data: company +-----------+------------+-----------------+----------------+ | companyid | signupdate | subscriptiondate| terminationdate| +-----------+------------+-----------------+----------------+ | 101 | 2019-06-05 | 2019-06-06 | 2019-06-25 | -- churn < 30d (not retained) | 102 | 2019-06-10 | 2019-06-15 | NULL | -- retained | 103 | 2019-06-20 | NULL | NULL | -- retained (no termination) | 104 | 2019-07-01 | 2019-07-02 | 2019-07-31 | -- churn at 30d (retained) | 105 | 2019-07-15 | 2019-07-16 | 2019-07-10 | -- churn before signup? (data quality) | 106 | 2025-08-20 | 2025-08-21 | NULL | -- censored; exclude from 30d | 107 | 2020-01-01 | 2020-01-02 | 2020-02-15 | -- retained | 108 | 2020-01-10 | NULL | 2020-01-25 | -- churn < 30d (not retained) +-----------+------------+-----------------+----------------+ Questions to address in your solution: - Provide SQL (PostgreSQL) that calculates the cohort table with the censoring rule and the day-30 boundary condition as defined. - Show how you would optionally add paid-only retention by excluding companyids in Free_Subs via an additional column paid_d30_retention_rate. - Explain in comments how you would handle obvious data-quality anomalies (e.g., terminationdate < signupdate).

Quick Answer: This question evaluates SQL-based cohort analysis, 30-day retention metric calculation, handling of right-censoring, and data-quality reasoning within the Analytics & Experimentation domain for a Data Scientist role, emphasizing practical application of SQL and time-windowed data wrangling.

Related Interview Questions

  • Design an experiment for pricing page redesign - Intuit (easy)
  • Extract insights from a multi-entry funnel scorecard - Intuit (easy)
  • Design an experiment to evaluate an onboarding progress bar - Intuit (easy)
  • Diagnose rising delivery cost precisely - Intuit (hard)
  • Build cohort 30-day retention from signup date - Intuit (medium)
Intuit logo
Intuit
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Analytics & Experimentation
8
0
Loading...

Monthly 30-Day Retention Cohort (PostgreSQL)

Context

You are given a table of companies with signup and (optional) termination dates. Define monthly cohorts by the signup month and compute 30-day retention per cohort. Use a fixed as_of_date to handle right-censoring.

Retention rule: a company is retained at day 30 if terminationdate is NULL or terminationdate ≥ signupdate + 30 days. Churn strictly before day 30 is not retained; churn on day 30 counts as retained.

Right-censoring: exclude any signup whose 30-day window has not fully elapsed by as_of_date (i.e., where signupdate + 30 days > as_of_date).

Do not exclude Free_Subs from the base metric; if you want paid-only retention, add an additional column that excludes any companyid present in Free_Subs.

Schema and Sample Data

Table: company

  • companyid (INT)
  • signupdate (DATE)
  • subscriptiondate (DATE)
  • terminationdate (DATE)

Sample rows:

  • (101, 2019-06-05, 2019-06-06, 2019-06-25) — churn < 30d (not retained)
  • (102, 2019-06-10, 2019-06-15, NULL) — retained
  • (103, 2019-06-20, NULL, NULL) — retained (no termination)
  • (104, 2019-07-01, 2019-07-02, 2019-07-31) — churn on day 30 (retained)
  • (105, 2019-07-15, 2019-07-16, 2019-07-10) — termination before signup (data quality)
  • (106, 2025-08-20, 2025-08-21, NULL) — censored as of 2025-09-01; exclude from 30d calculation
  • (107, 2020-01-01, 2020-01-02, 2020-02-15) — retained
  • (108, 2020-01-10, NULL, 2020-01-25) — churn < 30d (not retained)

Optional table for paid-only metric:

  • Free_Subs(companyid)

Task

Produce a monthly cohort table of 30-day retention based on signupdate.

  • cohort_month = date_trunc('month', signupdate)
  • cohort_size = number of companies in the cohort (after right-censoring and any data-quality handling)
  • d30_retained = number of companies retained at day 30
  • d30_retention_rate = d30_retained / cohort_size (3 decimals)

Parameters and rules:

  1. A company is retained at day 30 if terminationdate is NULL or terminationdate ≥ signupdate + INTERVAL '30 days'.
  2. Handle right-censoring: exclude signups where signupdate + INTERVAL '30 days' > as_of_date. Use as_of_date = '2025-09-01'.
  3. Return columns:
    • cohort_month (DATE, first day of month)
    • cohort_size (INT)
    • d30_retained (INT)
    • d30_retention_rate (NUMERIC, 3 decimals)
  4. Do not exclude Free_Subs in the base metric. Optionally add a paid-only column paid_d30_retention_rate that excludes companyids present in Free_Subs.
  5. In comments, explain how to handle data-quality anomalies (e.g., terminationdate < signupdate).

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Analytics & Experimentation•More Intuit•More Data Scientist•Intuit Data Scientist•Intuit Analytics & Experimentation•Data Scientist Analytics & Experimentation
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.