Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Monthly Upgrades and MoM Growth
00:00
5 left

Monthly Upgrades and MoM Growth

MediumSQL · PostgreSQL

Problem

Write a query to find the monthly active users who upgraded their subscription tier, showing the month-over-month growth rate.

Use user_activity records to identify active users and subscription_changes records to identify upgrades occurring in the same calendar month. Include only users active during the month of their upgrade.

Output

  1. One row per month with at least one qualifying user.
  2. Columns: month, monthly_active_upgraded_users, and mom_growth_rate_pct.
  3. Show growth as a percentage rounded to two decimal places. The first month should have a NULL growth rate.
  4. Sort chronologically by month.

Schema

user_activity
ColumnTypeDescription
activity_idPKINTUnique activity record identifier
user_idINTHubSpot user identifier associated with the activity
activity_atTIMESTAMPTimestamp when the user was active
subscription_changes
ColumnTypeDescription
change_idPKINTUnique subscription change identifier
user_idINTHubSpot user identifier affected by the change
changed_atTIMESTAMPTimestamp when the subscription changed
change_typeVARCHAR(20)Type of subscription change
old_tierVARCHAR(30)Subscription tier before the change
new_tierVARCHAR(30)Subscription tier after the change
Tablesuser_activitysubscription_changes
Interviewer

Your question is Monthly Upgrades and MoM Growth. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.