AnalystPath

A/B Test Sample Ratio Mismatch (SRM) Check

SQLMediumMid levelMicrosoft~15 min

Problem

**[Asked at Microsoft]**

An A/B test is designed as a 50/50 split. A **Sample Ratio Mismatch (SRM)** occurs
when the control share deviates from 50% by more than 5 percentage points.

Return `experiment_id`, `control_count`, `treatment_count`, and `is_srm`
(1 = SRM detected, 0 = balanced), ordered by experiment.

Tables

Example rows — the live problem includes the full dataset.

assignments
assignment_idexperiment_iduser_idvariant

Expected output

Your answer should return 2 rows with the columns experiment_id, control_count, treatment_count, is_srm.

Starter code (SQL)

SELECT *
FROM assignments;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions