i have created fnDiscountPrice() that references the item id so that it will find the discount price for one item now I'm needing to find the total price of all the products with that ID. so i have a function that receives the ItemID and then multiplys the discount price found in fnDiscountPrice() with the same ID by the quantity. Code shown below.
CREATE FUNCTION dbo.fnItemTotal
(@ItemID INT = 0)
RETURNS Table
RETURN (SELECT ItemID, SUM(dbo.fnDiscountPrice(@ItemID) * Quantity) AS TimeTotal
FROM OrderItems
GROUP BY ItemID)
I keep getting an error of "Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fnDiscountPrice", or the name is ambiguous."
dbo.fnDiscountPrice
a scalar valued function or table valued function. You are using it as if it is a scalar valued function but if you have created a table valued function (which is better) you need to change the way you use it.