Answer :
Answer:
SELECT WarehouseID, SUM(QuantityOnHand) AS TotalItemsOnHandLT3
FROM INVENTORY
WHERE QuantityOnHand < 3
GROUP BY WarehouseID
ORDER BY TotalItemsOnHandLT3 DESC;
Explanation:
SELECT statement is used to select the columns from the table. Here the columns displayed by SELECT are WareHouseID, Sum of QuantityOnHand which is named as TotalItemsOnHandLT3 using AS which is called alias which is a temporary name to represent one or columns. WHERE clause here depicts a condition that omits all SKU items that have three or more items on hand from the sum. GROUP BY is used to group the resultant set by one or more columns like here it is grouped by WarehouseID. ORDER BY is used to display the result of TotalItemsOnHandLT3 column in descending order.