Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Retail Sales Analysis
00:00
5 left

SQL Retail Sales Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze NIKE retail sales by store, product, and week, including joins across sales, inventory, and store dimension tables.

Return all sales combinations associated with a known Nike store. Preserve sales rows without a matching inventory snapshot and classify inventory status based on available units.

Output

  1. One row per store, product, and calendar week, with columns store_id, store_name, region, product_id, week_start, total_units_sold, total_sales, ending_inventory_units, and inventory_status.
  2. Include missing inventory as a visible result, and order by store_id, week_start, and product_id.

Schema

nike_sales
ColumnTypeDescription
sale_idPKINTUnique retail sale identifier
store_idINTNike store that recorded the sale
product_idVARCHAR(20)Nike product identifier
sale_dateDATEDate on which the sale occurred
units_soldINTNumber of units sold
net_salesDECIMAL(12,2)Net sales amount in local reporting currency
nike_inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory snapshot identifier
store_idINTStore holding the inventory
product_idVARCHAR(20)Nike product identifier
week_startDATEMonday starting the inventory week
ending_unitsINTUnits available at the end of the week
nike_store_dim
ColumnTypeDescription
store_idPKINTUnique Nike store identifier
store_nameVARCHAR(100)Nike store display name
regionVARCHAR(50)Geographic sales region
Tablesnike_salesnike_inventorynike_store_dim
Interviewer

Your question is SQL Retail Sales Analysis. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.