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
Active Subscription Revenue by Customer
00:00
5 left

Active Subscription Revenue by Customer

EasySQL · PostgreSQL

Problem

PetBox wants a report of currently active subscriptions and the revenue tied to each subscribed product. Write a SQL query to return one row per active subscription.

Requirements

  1. Return the customer name, product name, next shipment date, and product price as revenue
  2. Include only subscriptions where status = 'active'
  3. Join subscriptions to customers and products using their keys
  4. Order the final result by customer name, then product name

Sample Output

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique identifier for each customer
nameVARCHAR(255)Customer's full name
emailVARCHAR(255)Customer email address
created_atTIMESTAMPTimestamp when the customer account was created
products
ColumnTypeDescription
product_idPKINTUnique identifier for each product
nameVARCHAR(255)Product name
categoryVARCHAR(255)Product category
priceDECIMAL(10,2)Product price
subscriptions
ColumnTypeDescription
subscription_idPKINTUnique identifier for each subscription
customer_idINTReference to the customer
product_idINTReference to the product
start_dateDATEDate the subscription started
next_shipment_dateDATEDate of the next scheduled shipment
statusVARCHAR(255)Current subscription status
Tablescustomersproductssubscriptions
Interviewer

Your question is Active Subscription Revenue by Customer. Start with the requirements and the three 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.