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

Conversion Rate by User Segment

MediumSQL · PostgreSQL

Problem

Amazon DSP analysts need to compare advertising performance across audience segments. Using users and impression-level events, write a PostgreSQL query that calculates the user conversion rate during June 2025.

Requirements

  1. Return every user segment, including segments with no impressions during the period. Label users with a missing segment as Unclassified.
  2. Calculate distinct exposed users, distinct converted users, and conversion rate per segment. An impression with clicked = TRUE counts as a conversion.
  3. Restrict events to June 1 through June 30, 2025, and return conversion rate as converted users divided by exposed users. Return 0.0000 when no users were exposed.
  4. Order results alphabetically by segment.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
user_segmentVARCHAR(30)Amazon DSP audience segment
ad_impressions
ColumnTypeDescription
impression_idPKINTUnique impression identifier
user_idINTUser who received the impression
campaign_nameVARCHAR(100)Amazon DSP campaign name
impression_dateDATEDate when the impression occurred
clickedBOOLEANWhether the impression produced a click
Tablesusersad_impressions
Interviewer

Your question is Conversion Rate by User Segment. 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.