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 Join for Campaign and Conversion
00:00
5 left

SQL Join for Campaign and Conversion

MediumSQL · PostgreSQL

Problem

Andreessen Horowitz uses campaign performance data to evaluate outreach across its founder, technology, and investment content. Write a PostgreSQL query that joins campaign touchpoints with customer conversion records and reports performance for campaigns launched in Q1 2025.

Requirements

  1. Include every Q1 2025 campaign, including campaigns with no recorded touchpoints.
  2. Count distinct customers reached by each campaign.
  3. Count a customer as converted when a conversion occurred within 30 days of that customer's first touch for the campaign.
  4. Calculate the conversion rate as a percentage, returning 0.00 for campaigns with no reached customers. Sort by conversion rate descending, then campaign ID.

Representative sample data

Schema

campaigns
ColumnTypeDescription
campaign_idPKINTUnique campaign identifier
campaign_nameVARCHAR(100)Campaign name
channelVARCHAR(40)Marketing channel
launch_dateDATECampaign launch date
budgetDECIMAL(12,2)Campaign budget
campaign_touches
ColumnTypeDescription
touch_idPKINTUnique touchpoint identifier
campaign_idINTReferences campaigns.campaign_id
customer_idINTCustomer receiving the touch
touched_atDATEDate of the campaign touch
conversions
ColumnTypeDescription
conversion_idPKINTUnique conversion identifier
customer_idINTCustomer who converted
conversion_dateDATEDate of conversion
conversion_typeVARCHAR(40)Type of conversion
Tablescampaignscampaign_touchesconversions
Interviewer

Your question is SQL Join for Campaign and Conversion. 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.