This prompt evaluates SQL proficiency in time-windowed cohort analysis, event deduplication, date arithmetic, and per-variant aggregation for A/B experiments, categorized under Data Manipulation (SQL/Python) and targeted at an intermediate-level Data Scientist role.
You are analyzing an A/B test for a marketing campaign that offers a free 1‑month trial.
Assume all timestamps are in UTC.
experiment_assignmentsOne row per user assignment.
user_id
BIGINT
experiment_id
STRING
variant
STRING -- 'control' or 'treatment'
assigned_at
TIMESTAMP -- first time user was assigned (sticky)
trial_startsOne row per trial start.
user_id
BIGINT
trial_started_at
TIMESTAMP
sessionsOne row per user session.
user_id
BIGINT
session_start_at
TIMESTAMP
assigned_at
.
session_start_at
in the window
[trial_started_at + 30 days, trial_started_at + 37 days)
.
Write a single SQL query that outputs one row per variant with:
variant
assigned_users
converted_users
signup_rate
retained_users
retention_rate_among_converted
Notes: