Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.