Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Time From Trial to First Paid

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

Your question is Time From Trial to First Paid. 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

Adobe wants to measure how quickly trial users convert to paid plans. Write a SQL query to compute the elapsed time between each user's first trial sign-up and their first paid transaction.

Requirements

  1. Use the earliest trial_signup_at per user from the login table.
  2. Use the earliest paid_transaction_at per user from the action log table.
  3. Return only users who have both events.
  4. Output the elapsed time in hours, rounded to 2 decimals.

Schema

user_logins
ColumnTypeDescription
login_idPKINTPrimary key for the login event
user_idINTUser identifier
trial_signup_atTIMESTAMPTimestamp when the user first signed up for a trial
login_atTIMESTAMPTimestamp of a daily login event
action_logs
ColumnTypeDescription
action_idPKINTPrimary key for the action event
user_idINTUser identifier
action_typeVARCHAR(50)Type of action performed, such as paid_transaction
action_atTIMESTAMPTimestamp when the action occurred
Tablesuser_loginsaction_logs
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results