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 Conversion Rate by Channel
00:00
5 left

SQL Conversion Rate by Channel

MediumSQL · PostgreSQL

Problem

L.L.Bean marketing analysts need daily conversion reporting for campaign channels such as email, SMS, paid search, and social media. A customer is considered converted when they have a completed order on the same date as a delivered campaign touch.

Write a PostgreSQL query that calculates campaign conversion rate by touch date and channel for March 1 through March 3, 2026.

Requirements

  1. Include every delivered campaign channel and date, including groups with zero completed orders.
  2. Count distinct reached customers and distinct converted customers.
  3. Calculate conversion_rate as converted customers divided by reached customers, expressed as a percentage rounded to two decimals.
  4. Display missing channel values as Unassigned, and sort by date followed by channel.

Schema

campaign_touches
ColumnTypeDescription
touch_idPKINTUnique identifier for a campaign touch
customer_idINTCustomer who received the touch
touch_dateDATEDate the campaign touch was sent
channelVARCHAR(40)Marketing channel used for the touch
campaign_nameVARCHAR(100)Name of the L.L.Bean campaign
deliveredBOOLEANWhether the touch was successfully delivered
orders
ColumnTypeDescription
order_idPKINTUnique identifier for an order
customer_idINTCustomer who placed the order
order_dateDATEDate the order was placed
order_statusVARCHAR(20)Current order status
order_totalNUMERIC(10,2)Total value of the order
Tablescampaign_touchesorders
Interviewer

Your question is SQL Conversion Rate by Channel. 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.