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
Top 3 Products Per Region
00:00
5 left

Top 3 Products Per Region

MediumSQL · PostgreSQL

Problem

Abbott's commercial analytics team needs a regional view of its best-selling medical device products. Write a PostgreSQL query for the last completed quarter, defined here as 2025-04-01 through 2025-06-30.

Requirements

  1. Include only orders with status = 'Completed' during the specified quarter.
  2. Join regions, orders, order items, and products to calculate total units sold by region and product.
  3. Return the top three products within each region, ranking by total units sold descending and resolving ties by product_name ascending.
  4. Exclude products with non-positive or NULL quantities and return regions with qualifying sales only.

Schema

regions
ColumnTypeDescription
region_idPKINTEGERUnique Abbott sales region identifier
region_nameVARCHAR(100)Sales region name
sales_orders
ColumnTypeDescription
order_idPKINTEGERUnique sales order identifier
region_idINTEGERRegion assigned to the order
order_dateDATEDate the order was placed
statusVARCHAR(20)Order processing status
sales_order_items
ColumnTypeDescription
order_idPKINTEGERRelated sales order identifier
product_idPKINTEGERRelated medical device product identifier
quantityINTEGERNumber of units sold
products
ColumnTypeDescription
product_idPKINTEGERUnique product identifier
product_nameVARCHAR(150)Abbott medical device product name
Tablesregionssales_orderssales_order_itemsproducts
Interviewer

Your question is Top 3 Products Per Region. Start with the requirements and the four 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.