我需要你的帮助。我有这段代码来查询我的出租、库存和我的网点上的机器,但这只有在我输入 itemID 时才有效,这意味着它一次只能查询一个项目。我需要查询出租和销售的机器数量,与现有库存数量平行。
alter procedure GetItemsForQueries
@itemID varchar(15)
as begin
select i.ItemName, m.MachineModel, i.SellingPrice, i.QuantityOnHand,
(select COUNT(*) from ClientMachine where AcquisitionType = 'Rental' and ItemID = @itemID) as 'Quantity on Rentals',
(select COUNT(*) from OutletMachine where ItemID = @itemID) as 'Quantity on Outlets'
from Item i inner join Machine m on (m.ItemID = i.ItemID)
where i.ItemID = @itemID
end