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
Identify High-Cost Inventory Categories
00:00
5 left

Identify High-Cost Inventory Categories

MediumSQL · PostgreSQL

Problem

Tell me how you would identify top-selling product categories that currently have high inventory holding costs and what actions you would take.

Use the provided categories, products, and product_metrics tables. Treat the latest available metric date as current, identify categories in the top three by units sold with above-average holding cost, and include a concise recommended action.

Output

  1. One row per qualifying category.
  2. Return category_name, total_units_sold, total_holding_cost, sales_rank, and recommended_action.
  3. Sort by sales_rank ascending, then category_name ascending.

Schema

categories
ColumnTypeDescription
category_idPKINTUnique product category identifier
category_nameVARCHAR(100)Product category name
products
ColumnTypeDescription
product_idPKINTUnique product identifier
category_idINTCategory containing the product
product_nameVARCHAR(150)Product name
product_metrics
ColumnTypeDescription
metric_idPKINTUnique product metric record identifier
product_idINTProduct associated with the metrics
metric_dateDATEDate on which the metrics were recorded
units_soldINTUnits sold during the metric period
average_inventory_unitsINTAverage inventory units held during the period
unit_costNUMERIC(10,2)Inventory cost per unit
annual_holding_rateNUMERIC(5,2)Annual inventory holding cost rate
Tablescategoriesproductsproduct_metrics
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.

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.