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
Start free
Top Monthly Product Category by Region
00:00
5 left

Top Monthly Product Category by Region

HardSQL · PostgreSQL

Problem

How would you solve scenario-based analytics questions using SQL for a typical Tiger Analytics client dataset?

Using the provided customers, orders, and products tables, write a query for completed orders during 2025. Return the highest-revenue product category for each region and calendar month. Exclude records that cannot be associated with a customer region or product category.

Output

  1. One row per region and month
  2. Columns: report_month, region, category, completed_orders, revenue, and category_rank
  3. Include only the highest-revenue category per region and month; break revenue ties alphabetically by category
  4. Order by report_month, then region

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer display name
regionVARCHAR(50)Customer reporting region
orders
ColumnTypeDescription
order_idPKINTUnique order identifier
customer_idINTCustomer who placed the order
product_idINTProduct included in the order
order_dateDATEDate the order was placed
statusVARCHAR(20)Order processing status
order_amountDECIMAL(12,2)Order revenue amount
products
ColumnTypeDescription
product_idPKINTUnique product identifier
product_nameVARCHAR(120)Product name
categoryVARCHAR(60)Product reporting category
Tablescustomersordersproducts
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.