Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for MoM Retention

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL for MoM Retention. Start with the requirements and the two tables on the right.

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.

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
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results