Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fnDiscountPrice", or the name is ambiguous 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."
Assuming that the column name returned from dbo.fnDiscountPrice is DiscountPrice you could use it like this.

CREATE FUNCTION dbo.fnItemTotal 
    (@ItemID INT = 0)
    RETURNS Table

RETURN (SELECT O.ItemID, SUM(DP.DiscountPrice * O.Quantity) AS TimeTotal
        FROM dbo.fnDiscountPrice(@ItemID) as DP
          CROSS APPLY OrderItems as O
        GROUP BY O.ItemID)