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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
SQL for Top Product Categories
00:00
5 left

SQL for Top Product Categories

MediumSQL · PostgreSQL

Problem

How would you write a SQL query to identify the top-performing Goodyear product categories across different sales regions?

Use the Goodyear sales data for completed transactions in calendar year 2025. Return the highest-revenue category or categories within each region, preserving ties.

Output

  1. One row per top-performing category and region.
  2. Columns: region_name, category_name, total_revenue, and category_rank.
  3. Include only regions with qualifying sales, ordered by region, rank, and category name.

Schema

sales_transactions
ColumnTypeDescription
sale_idPKINTUnique sales transaction identifier
product_idINTSold product identifier
region_idINTSales region identifier
sale_dateDATETransaction date
quantityINTNumber of units sold
unit_priceDECIMAL(10,2)Price per unit
sale_statusVARCHAR(20)Transaction status
products
ColumnTypeDescription
product_idPKINTUnique product identifier
product_nameVARCHAR(100)Goodyear product name
category_nameVARCHAR(50)Product category
sales_regions
ColumnTypeDescription
region_idPKINTUnique sales region identifier
region_nameVARCHAR(50)Sales region name
Tablessales_transactionsproductssales_regions
Interviewer

Your question is SQL for Top Product Categories. 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.