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 Experiment Case Study
00:00
5 left

SQL and Experiment Case Study

HardSQL · PostgreSQL

Problem

Describe how you would combine basic SQL joins and window functions with A/B testing to answer a case study question.

Use the supplied assignment, user, and order data. Calculate variant-level conversion and order metrics, compare each variant with control group A, and rank variants by conversion rate.

Output

  1. One row per experiment variant.
  2. Include variant, assigned_users, converted_users, conversion_rate, total_orders, total_revenue, avg_order_value, lift_vs_control, and variant_rank.
  3. Include variants with no orders, treat an assigned user with at least one order as converted, and sort by variant_rank, then variant.

Schema

experiment_assignments
ColumnTypeDescription
assignment_idPKINTUnique assignment record identifier
user_idINTAssigned user's identifier
variantVARCHAR(20)Experiment variant, with A as control
users
ColumnTypeDescription
user_idPKINTUnique user identifier
platformVARCHAR(20)Primary application platform
orders
ColumnTypeDescription
order_idPKINTUnique order identifier
user_idINTUser who placed the order
order_amountDECIMAL(10,2)Order value
Tablesexperiment_assignmentsusersorders
Interviewer

Your question is SQL and Experiment Case Study. 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.