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
Troubleshoot Inventory File Discrepancies
00:00
5 left

Troubleshoot Inventory File Discrepancies

MediumSQL · PostgreSQL

Problem

You are given retailer inventory snapshots and the corresponding inventory currently shown in the Instacart app. Write a PostgreSQL query that helps you troubleshoot discrepancies by returning the SKUs where the two sources disagree for the latest snapshot date, along with the prior app state and the mismatch type.

Use the latest snapshot_date available in the retailer file, compare it to the matching app inventory on that date, and surface only rows where the retailer and app quantities differ or where a SKU exists in one source but not the other. Include the retailer quantity, app quantity, previous app quantity, and a discrepancy_reason that distinguishes quantity mismatches from missing SKUs. Order the output so the most recently changed items appear first.

Schema

retailer_inventory_files
ColumnTypeDescription
file_idPKINTPrimary key for each retailer file row
retailer_idINTRetailer identifier
snapshot_dateDATEFile date for the inventory snapshot
skuVARCHAR(50)Retailer SKU
file_qtyINTQuantity reported in the retailer file
instacart_app_inventory
ColumnTypeDescription
app_idPKINTPrimary key for each app inventory row
retailer_idINTRetailer identifier
snapshot_dateDATEDate shown in the Instacart app
skuVARCHAR(50)SKU shown in the app
app_qtyINTQuantity shown in the app
updated_atTIMESTAMPTime the app quantity was last updated
Tablesretailer_inventory_filesinstacart_app_inventory
Interviewer

Your question is Troubleshoot Inventory File Discrepancies. 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.