Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.