Interview Query

Trial Test Analysis

Start Timer

0:00:00

Upvote
1
Downvote
Save question
Mark as completed
View comments (2)
Next question

Let’s say we have tables ab_tests and subscriptions. We need to analyze the effectiveness of a trial period experiment.

Write a query to calculate the conversion rate for each variant, where the conversion criteria differs based on the variant:

  • For control group: Count as converted if they subscribed anytime after entering the experiment

  • For trial group: Count as converted only if they subscribed AND (either haven’t cancelled OR stayed subscribed for at least 7 days before cancelling).

Note: Please represent the conversion rate as out of 100 rounded to two digits (i.e. 35.5% is 35.50)

ab_tests table

Column Type
user_id INTEGER
variant VARCHAR
created_at TIMESTAMP

subscriptions table

Column Type
user_id INTEGER
created_at TIMESTAMP
cancelled_at TIMESTAMP

Output

Column Type
variant VARCHAR
conversion_rate FLOAT
total_users INTEGER
.
.
.
.
.


Comments

Loading comments