Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 feedbackSuccess 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 and Probability Interview Prep
00:00
5 left

SQL and Probability Interview Prep

MediumSQL · PostgreSQL

Problem

How would you approach a medium difficulty SQL exercise combined with probability questions in an interview?

Use the provided experiment exposure and conversion-event data. Write a PostgreSQL query that calculates the probability of conversion for each non-null variant in experiment 1 during January 2026, then ranks variants by that probability.

Output

  1. One row per variant, with variant, exposed_exposures, converted_exposures, conversion_probability, and variant_rank.
  2. Include only January exposures belonging to experiment 1 and exclude null variants. Count an exposure as converted when it has at least one conversion event.
  3. Sort by variant_rank ascending, then variant ascending.

Schema

experiments
ColumnTypeDescription
experiment_idPKINTUnique experiment identifier
experiment_nameVARCHAR(100)Experiment display name
statusVARCHAR(20)Experiment lifecycle status
experiment_exposures
ColumnTypeDescription
exposure_idPKINTUnique exposure identifier
experiment_idINTExperiment associated with the exposure
user_idINTUser receiving the exposure
variantVARCHAR(30)Assigned experiment variant
exposed_atDATEDate of exposure
conversion_events
ColumnTypeDescription
event_idPKINTUnique event identifier
exposure_idINTExposure associated with the event
event_typeVARCHAR(30)Type of event recorded
event_atDATEDate of event
Tablesexperimentsexperiment_exposuresconversion_events
Interviewer

Your question is SQL and Probability Interview Prep. 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.