Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Conversion Rate by Channel

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

Your question is SQL Conversion Rate by Channel. Start with the requirements and the two tables 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

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
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results