Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL for MoM Retention
00:00
5 left

SQL for MoM Retention

HardSQL · PostgreSQL

Problem

Thumbtack’s Marketing Analytics team wants to measure how consistently service professionals who joined the platform in 2024 remain active. Write a PostgreSQL query that calculates month-over-month retention by join-month cohort.

Requirements

  1. Include only service professionals whose joined_at date falls in 2024.
  2. Treat a professional as active in a month when at least one activity record exists during that month.
  3. For each cohort and activity month after the join month, return the previous-month active count, retained-professional count, and retention rate. Define retention as retained professionals divided by professionals active in the previous month.
  4. Deduplicate multiple activity records for the same professional in the same month and order results by cohort month and activity month.

Schema

service_professionals
ColumnTypeDescription
professional_idPKINTUnique service professional identifier
professional_nameVARCHAR(100)Professional display name
joined_atDATEDate the professional joined Thumbtack
cityVARCHAR(80)Primary service city
specialtyVARCHAR(100)Primary service category
professional_activity
ColumnTypeDescription
activity_idPKINTUnique activity record identifier
professional_idINTReferences service_professionals.professional_id
activity_atDATEDate of activity on Thumbtack
activity_typeVARCHAR(40)Type of professional activity
Tablesservice_professionalsprofessional_activity
Interviewer

Your question is SQL for MoM Retention. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.