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
Monthly Conversion Rate SQL
00:00
5 left

Monthly Conversion Rate SQL

MediumSQL · PostgreSQL

Problem

Write a SQL query to calculate monthly campaign conversion rates by channel.

Use campaign_touches and conversions. Count distinct leads reached through each non-null channel, and count a lead as converted when it has a completed conversion on or after the touch date within the same calendar month.

Output

  1. One row per month and channel.
  2. Columns: month_start, channel, reached_leads, converted_leads, and conversion_rate_pct.
  3. Include channels with zero conversions, calculate the rate as a percentage rounded to two decimal places, and order by month followed by channel.

Schema

campaign_touches
ColumnTypeDescription
touch_idPKINTUnique campaign touch identifier
lead_idVARCHAR(20)Lead reached by the campaign touch
channelVARCHAR(40)Marketing channel used for the touch
touch_dateDATEDate of the campaign touch
campaign_idVARCHAR(20)Campaign identifier associated with the touch
conversions
ColumnTypeDescription
conversion_idPKINTUnique conversion identifier
lead_idVARCHAR(20)Lead associated with the conversion
conversion_dateDATEDate the conversion occurred
conversion_statusVARCHAR(20)Conversion processing status
Tablescampaign_touchesconversions
Interviewer

Your question is Monthly Conversion Rate SQL. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.