Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Month-over-Month Growth

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

Your question is SQL Month-over-Month Growth. 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

GoFundMe’s Marketing Analytics team wants to monitor the monthly creation of new donation campaigns. Write a PostgreSQL query that calculates month-over-month growth across the full campaign date range.

Requirements

  1. Count eligible campaigns by calendar month using created_at.
  2. Exclude campaigns with status = 'deleted' and campaigns attributed to the test source type. Treat campaigns without a source record as organic.
  3. Include months with zero eligible campaigns between the first and last eligible campaign month.
  4. Return the current count, prior-month count, and growth percentage. Return NULL for growth when there is no prior month or the prior count is zero.

Schema

campaigns
ColumnTypeDescription
campaign_idPKINTEGERUnique GoFundMe campaign identifier
titleVARCHAR(150)Campaign title
created_atTIMESTAMPTimestamp when the campaign was created
statusVARCHAR(20)Campaign lifecycle status
campaign_sources
ColumnTypeDescription
source_idPKINTEGERUnique source attribution record
campaign_idINTEGERReferenced GoFundMe campaign
source_typeVARCHAR(30)Campaign acquisition source
Tablescampaignscampaign_sources
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results