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 Three Performing Sales Regions
00:00
5 left

Top Three Performing Sales Regions

MediumSQL · PostgreSQL

Problem

Business Context

Merck's commercial analytics team is reviewing 2025 net sales for Keytruda across active sales regions. The dashboard should identify the strongest regions using completed transactions only.

Task

Write a PostgreSQL query that returns the top three active sales regions by total Keytruda net sales during calendar year 2025.

Requirements

  1. Join the region and sales tables, retaining active regions even when they have no qualifying transactions.
  2. Include only completed Keytruda transactions dated from 2025-01-01 through 2025-12-31.
  3. Aggregate net sales by region, treat missing sales totals as zero, rank regions from highest to lowest revenue, and return the top three.
  4. Use a deterministic secondary sort by region name when totals are tied.

Schema

sales_regions
ColumnTypeDescription
region_idPKINTEGERUnique sales region identifier
region_nameVARCHAR(100)Display name of the sales region
is_activeBOOLEANIndicates whether the region is active
regional_sales
ColumnTypeDescription
sale_idPKINTEGERUnique sales transaction identifier
region_idINTEGERSales region associated with the transaction
product_nameVARCHAR(100)Merck product sold
sale_dateDATEDate when the sale was recorded
statusVARCHAR(30)Transaction processing status
net_sales_usdNUMERIC(14,2)Net sales amount in US dollars
Tablessales_regionsregional_sales
Interviewer

Your question is Top Three Performing Sales Regions. 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.