BoggyBayouBoy
asked on
Returning Total Inventory Quantity from the AdventureWorks Database
I would like to return a single row which returns the total items in stock for a given productID.
Currently my query is as follows:
SELECT s.SalesOrderID,s.SalesOrde rDetailID, s.OrderQty, s.ProductID, s.UnitPrice, s.unitPriceDiscount,
s.LineTotal, pri.Quantity, p.Name as Name
from Sales.SalesOrderDetail s
INNER JOIN production.product p
ON p.ProductID = s.ProductID
inner join production.productInventor y pri on pri.ProductID = s.ProductID
where s.SalesOrderID =@SalesOrderID
Because a single productID can exist in multiple locations, this query can return multiple rows - which I don't want.
Experts, How can I SUM the pri.Quantity and return a single row?? Thanks in advance!
Currently my query is as follows:
SELECT s.SalesOrderID,s.SalesOrde
s.LineTotal, pri.Quantity, p.Name as Name
from Sales.SalesOrderDetail s
INNER JOIN production.product p
ON p.ProductID = s.ProductID
inner join production.productInventor
where s.SalesOrderID =@SalesOrderID
Because a single productID can exist in multiple locations, this query can return multiple rows - which I don't want.
Experts, How can I SUM the pri.Quantity and return a single row?? Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER