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
Year-over-Year Product Growth
00:00
5 left

Year-over-Year Product Growth

MediumSQL · PostgreSQL

Problem

Stryker's commercial analytics team wants to monitor annual sales performance for the Mako product line. Write a PostgreSQL query that calculates year-over-year sales growth from the available sales records.

Requirements

  1. Join sales to products and include only products where product_line = 'Mako'.
  2. Aggregate total sales by calendar year using sale_date and sales_amount.
  3. Compare each year with the immediately preceding year and calculate growth as a percentage.
  4. Return the years in ascending order. Return NULL for the first year when no prior-year sales exist.

Schema

products
ColumnTypeDescription
product_idPKINTEGERUnique product identifier
product_nameVARCHAR(100)Name of the Stryker product
product_lineVARCHAR(50)Stryker product line associated with the product
sales
ColumnTypeDescription
sale_idPKINTEGERUnique sale identifier
product_idINTEGERProduct associated with the sale
sale_dateDATEDate on which the sale was recorded
sales_amountNUMERIC(12,2)Sales value for the transaction
Tablesproductssales
Interviewer

Your question is Year-over-Year Product 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.