Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Compare Campaign Performance Periods

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

Your question is Compare Campaign Performance Periods. Start with the requirements and the one table 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

Rippling's growth team launched a campaign in Rippling Spend on 2024-02-15 and wants a quick before-vs-after performance read. Write a SQL query to compare daily campaign performance for the periods before and after launch.

Requirements

  1. Use only the campaign_events table.
  2. Return one row per period: Before Launch and After Launch.
  3. For each period, calculate:
    • total_impressions
    • total_clicks
    • total_signups
    • ctr = total_clicks / total_impressions
    • signup_rate = total_signups / total_clicks
  4. Include only rows where event_date is between 2024-02-08 and 2024-02-21 inclusive.
  5. Treat dates before 2024-02-15 as Before Launch, and dates on or after 2024-02-15 as After Launch.
  6. Order the output by period so After Launch appears first.

Schema

campaign_events
ColumnTypeDescription
event_idPKINTPrimary key for each daily campaign record
event_dateDATEDate of campaign activity
campaign_nameVARCHAR(100)Campaign name in Rippling Spend
impressionsINTNumber of impressions recorded that day
clicksINTNumber of clicks recorded that day
signupsINTNumber of signups attributed that day
channelVARCHAR(50)Marketing channel
Tablescampaign_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results