我正在努力思考如何按照物品编号进行分组,并将数量添加到库存中。
我目前的代码是:
我得到了以下结果: 但我期望的输出是:
我目前的代码是:
SELECT dbo.InventoryItems.ItemNo, dbo.InventoryItems.DescriptionMed AS Description
, SUM(dbo.InventoryItems.QtyToStock) AS QtytoStock, dbo.Locations.LocationCode
FROM dbo.InventoryItems INNER JOIN dbo.Locations
ON dbo.InventoryItems.LocationID = dbo.Locations.LocationID
GROUP BY dbo.InventoryItems.ItemNo, dbo.InventoryItems.QtyToStock
, dbo.InventoryItems.DescriptionMed, dbo.Locations.LocationCode
HAVING (dbo.InventoryItems.ItemNo LIKE 'CL10%')
我得到了以下结果: 但我期望的输出是:
CL1000将只出现在两行中,它们的总和。 请帮忙!
ItemNo Description QTYtoStock LocationCode
CL1000 Square Seat Legs 4 CREST
CL1000 Square Seat Legs 93 DZ
CL1002 Square Low Back Sofa 5 DZ