Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Conversion Rate Before/After

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Conversion Rate Before/After. Start with the requirements and the two tables on the right.

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.

Problem

Business Context

Disney+ France launched a new Watchlist feature and wants to evaluate whether it improved session conversion. A converted session is one where converted is TRUE.

Task

Write a PostgreSQL query that compares conversion performance during the 30 days before and the 30 days after the Watchlist launch on 2025-03-15.

Requirements

  1. Join sessions to the Watchlist launch record and include only sessions in the two 30-day windows. The launch date belongs to the after period.
  2. Return one row for each period with session count, converted session count, and conversion rate.
  3. Treat NULL conversion flags as non-converted sessions, prevent division by zero, and order periods chronologically.

Schema

feature_launches
ColumnTypeDescription
launch_idPKINTUnique feature launch identifier
feature_nameVARCHAR(100)Name of the Disney+ France feature
launch_dateDATEDate when the feature launched
app_sessions
ColumnTypeDescription
session_idPKINTUnique viewing session identifier
user_idINTViewer identifier
session_dateDATEDate of the app session
convertedBOOLEANWhether the session resulted in conversion
Tablesfeature_launchesapp_sessions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results