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
SQL for Inconsistent Inventory
00:00
5 left

SQL for Inconsistent Inventory

MediumSQL · PostgreSQL

Problem

LEGO Group inventory feeds can contain multiple snapshots for the same set, warehouse, and date. Write a PostgreSQL query to identify conflicting records that may indicate a reporting or ingestion problem.

Requirements

  1. Find set and date combinations represented in at least two warehouses.
  2. Within those combinations, identify warehouses with multiple records whose on-hand or reserved quantities differ.
  3. Return the warehouse, region, LEGO set, snapshot date, record count, number of distinct quantity versions, and minimum and maximum quantities.
  4. Sort the results by snapshot date, set ID, and warehouse ID.

Schema

warehouses
ColumnTypeDescription
warehouse_idPKINTUnique warehouse identifier
warehouse_nameVARCHAR(100)LEGO Group warehouse name
regionVARCHAR(50)Geographic operating region
inventory_snapshots
ColumnTypeDescription
snapshot_idPKINTUnique inventory snapshot record
warehouse_idINTWarehouse that reported the snapshot
set_idINTLEGO set identifier
snapshot_dateDATEDate represented by the inventory snapshot
quantity_on_handINTPhysical units recorded at the warehouse
quantity_reservedINTUnits reserved for orders
Tableswarehousesinventory_snapshots
Interviewer

Your question is SQL for Inconsistent Inventory. 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.