Inventory value

calculations

Inventory value

Walmart SQL Interview Question

Walmart's finance team needs to know how much money is tied up in unsold stock for the end-of-year accounts.

For every product, show the product_name and the value of its stock at its current price as inventory_value. Products with no stock have a value of 0. Do not round the result.

Asked of

  • Data Analyst
  • Business Analyst
  • BI Analyst
  • Analytics Engineer

productsTable15 rows

Column NameType
product_idBIGINT
product_nameVARCHAR
categoryVARCHAR
brandVARCHAR
priceDOUBLE
discount_pctBIGINT
stock_quantityBIGINT
launch_dateDATE
is_activeBOOLEAN

productsExample Input

product_idproduct_namecategorybrandpricediscount_pctstock_quantitylaunch_dateis_active
1Wireless MouseElectronicsLogitech24.99101502023-02-14true
2Mechanical Keyboard ProElectronicsKeychron119NULL402023-05-01true
3Noise Canceling HeadphonesElectronicsSony299.991502022-11-20true
4Standing DeskFurnitureFlexispot349NULL122023-08-09true
5Ergonomic Chair ProFurnitureSteelcase1299552021-06-30true
6Desk LampFurnitureNULL39.5NULL802024-01-15true
7USB-C HubElectronicsAnker45202002023-03-22true
8Notebook SetStationeryMoleskine18NULL02022-09-01false

Example Output

product_nameinventory_value
Desk Lamp3160
Ergonomic Chair Pro6495
Mechanical Keyboard Pro4760
Noise Canceling Headphones0
Notebook Set0
Standing Desk4188
USB-C Hub9000
Wireless Mouse3748.5

Explanation

The Wireless Mouse is priced at 24.99 and has 150 in stock, so its stock is worth 3,748.50. The USB-C Hub is worth 45 × 200 = 9,000. The Noise Canceling Headphones have no stock, so their value is 0.

The example above is a small slice of the data. Your query runs against the full tables.