Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL Email Open Rate Drop Analysis
00:00
5 left

SQL Email Open Rate Drop Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to find the email open rate by campaign and identify campaigns with the largest drop over time.

Use the provided campaign, email send, and email event data. Treat a send as opened when it has at least one matching event with event_type = 'open'. Report campaigns with at least one decline between consecutive months.

Output

  1. One row per campaign and its largest month-over-month decline
  2. Columns: campaign_id, campaign_name, from_month, to_month, prior_open_rate, current_open_rate, drop_percentage
  3. Include only positive declines, ordered by drop_percentage descending, then campaign_id ascending

Schema

campaigns
ColumnTypeDescription
campaign_idPKINTUnique campaign identifier
campaign_nameVARCHAR(100)Campaign name
email_sends
ColumnTypeDescription
send_idPKINTUnique email send identifier
campaign_idINTCampaign associated with the send
recipient_emailVARCHAR(255)Recipient email address
sent_atTIMESTAMPTimestamp when the email was sent
email_events
ColumnTypeDescription
event_idPKINTUnique email event identifier
send_idINTEmail send associated with the event
event_typeVARCHAR(30)Event type, such as open or click
event_atTIMESTAMPTimestamp when the event occurred
Tablescampaignsemail_sendsemail_events
Interviewer

Your question is SQL Email Open Rate Drop Analysis. Start with the requirements and the three 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.