Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Month-over-Month Growth
00:00
5 left

SQL Month-over-Month Growth

MediumSQL · PostgreSQL

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
Interviewer

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