Signup Activation %

ASKED IN INTERVIEW
4pts
Tik Tok

Problem Statement

New users at TikTok sign up using their email. To activate their account, they must confirm a code sent via SMS.

Write an SQL query to find the activation rate of users. The activation rate is the percentage of users who confirmed their account via SMS within 24 hours of signing up.

Rules:

  • The activation rate should be rounded to 2 decimal places.
  • A user is considered activated only if they have a "Confirmed" status in the texts table and the time difference is <= 24 hours.
  • Users who never received a text or never confirmed should be included in the denominator (total signups).
  • Return a single column: confirm_rate.
  • You have access to the emails, texts, and a user_profiles table for metadata.
Tests your understanding of
JOIN, Dates, Aggregation and Subqueries

Input Tables

emails
email_id(INTEGER)user_id(INTEGER)signup_date(TIMESTAMP)
12577222022-06-14 10:00:00
43388212022-06-15 11:00:00
55133452022-06-16 12:00:00
60011222022-06-17 09:00:00
70099992022-06-18 14:00:00
texts
text_id(INTEGER)user_id(INTEGER)signup_action(VARCHAR)action_date(TIMESTAMP)
17722Confirmed2022-06-15 09:00:00
28821Confirmed2022-06-15 13:00:00
33345Not Confirmed2022-06-16 15:00:00
41122Confirmed2022-06-19 10:00:00
57722Not Confirmed2022-06-14 11:00:00
user_profiles
user_id(INTEGER)country(VARCHAR)
7722USA
8821UK
3345India
1122Brazil
9999Canada

Expected Output

confirm_rate(DECIMAL)
0.4

Tags

MediumASKED IN INTERVIEWJOINDatesAggregationSubqueries
20-25 min
42%

Hints