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
Analyze Sell-Out With SQL
00:00
5 left

Analyze Sell-Out With SQL

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze sell-out by category, store, and week, and identify the top-performing locations for The Coca-Cola.

Use the provided product, store, and sell-out data. Exclude records with an unknown category or missing sale date. Return the top two location ranks within each category and week, including ties.

Output

  1. One row per included category, week, and top-ranked store
  2. Columns: category, week_start, store_name, total_units, location_rank
  3. Sort by category, week, rank, and store name

Schema

products
ColumnTypeDescription
product_idPKINTProduct identifier
product_nameVARCHAR(100)Product name
categoryVARCHAR(80)Product category
stores
ColumnTypeDescription
store_idPKINTStore identifier
store_nameVARCHAR(120)Coca-Cola location name
cityVARCHAR(80)Store city
regionVARCHAR(40)Geographic region
sell_out
ColumnTypeDescription
sell_out_idPKINTSell-out record identifier
product_idINTReferenced product
store_idINTReferenced store
sold_atDATESale date
unitsINTUnits sold
Tablesproductsstoressell_out
Interviewer

Your question is Analyze Sell-Out With SQL. 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.