PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers

Quick Overview

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.

  • medium
  • OpenAI
  • Data Manipulation (SQL/Python)
  • Data Scientist

Write SQL to compute signup and retention lift

Company: OpenAI

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Technical Screen

You are analyzing an A/B test for a marketing campaign that offers a **free 1‑month trial**. Assume all timestamps are in **UTC**. ## Tables ### `experiment_assignments` One 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_starts` One row per trial start. - `user_id` BIGINT - `trial_started_at` TIMESTAMP ### `sessions` One row per user session. - `user_id` BIGINT - `session_start_at` TIMESTAMP ## Metric definitions - Experiment window: users assigned between **2025-01-01** and **2025-01-31** inclusive. - **Signup (trial start) conversion**: user starts a trial within **7 days** after `assigned_at`. - **D30 retention after signup**: for users who converted (started a trial within 7 days), the user is retained if they have **≥ 1 session** with `session_start_at` in the window **[trial_started_at + 30 days, trial_started_at + 37 days)**. ## Task 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: - Use distinct users (not event counts). - If a user has multiple trial starts, use the **earliest** one that satisfies the 7‑day conversion window after assignment. - A user can have many sessions; any qualifying session counts as retained.

Quick Answer: 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.

Last updated: May 7, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • Careers
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Write SQL for repeat churn - OpenAI (hard)
  • Handle repeated churn in SQL - OpenAI (hard)
  • Compute churn with re-subscriptions - OpenAI (hard)
  • Debug and harden trial-assignment Python code - OpenAI (Medium)
  • Write SQL for post-trial conversion cohorts - OpenAI (Medium)