Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL: Premium Upgrade Within 7 Days
00:00
5 left

SQL: Premium Upgrade Within 7 Days

MediumSQL · PostgreSQL

Problem

Given a table of Wix user logins and a table of purchases, write a query to calculate the conversion rate of users who upgraded to premium within 7 days of their first login.

Treat completed premium purchases occurring from the first login timestamp through, but not including, seven days later as conversions. Ignore null user IDs and purchases that are not completed premium upgrades.

Output

  1. Return one row with total_users, converted_users, and conversion_rate_pct.
  2. Calculate the rate as converted users divided by all users with a valid login.
  3. Return conversion_rate_pct rounded to two decimal places.

Schema

wix_user_logins
ColumnTypeDescription
login_idPKINTUnique login event identifier
user_idINTWix user identifier
login_atTIMESTAMPTimestamp of the login event
platformVARCHAR(30)Platform used for the login
wix_purchases
ColumnTypeDescription
purchase_idPKINTUnique purchase identifier
user_idINTWix user who made the purchase
purchased_atTIMESTAMPTimestamp of the purchase
planVARCHAR(30)Purchased plan type
statusVARCHAR(30)Purchase processing status
amountNUMERIC(10,2)Purchase amount
Tableswix_user_loginswix_purchases
Interviewer

Your question is SQL: Premium Upgrade Within 7 Days. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.