StoredProcedure reports an un-expected error

When creating a StoredProcedure (listed below) in Microsft SQL Server Express, I receive the following un-expected error:
Error 195: 'SUM' is not a recognized function name.

The listing of the StoredProcedure is as below:

CREATE PROCEDURE GetProductUnits
@ProductID AS int
AS
BEGIN
SELECT Products.ProductID, Products.ProductName, 
       Products.UnitsInStock, UnitsOnOrder, 
       SUM([Order details].quantity AS UnitsSold)
FROM  
       Products INNER JOIN [Order details] 
       ON Products.ProductID=[Order details].ProductID
WHERE 
       
Products.ProductID=@ProductID
GROUP BY 
       Products.ProductID, Products.ProductName, 
       Products.UnitsInStock, UnitsOnOrder
END

Any suggestion is highly appreciated.



Answer this question

StoredProcedure reports an un-expected error

  • sParc

    Try SUM([Order details].quantity) AS UnitsSold
  • StoredProcedure reports an un-expected error