I have a function that gets the recipeid. I am creating another function that shows the average price with recipename. How do I use the first function within the second function?
This is what I have so far. As can be seen, I am using a join for RecipeID, but I want it to use the 1st function I have (let's call it function1) that gets the ID instead. How do I go about this?
CREATE FUNCTION AveragePriceforRecipe() RETURNS @PriceTable TABLE (
[Amount] smallmoney,
[RecipeName] nvarchar(75)) AS
BEGIN
INSERT INTO @PriceTable
SELECT AVG(Amount)
FROM Prices JOIN
RecipePrices ON Prices.PriceID = RecipePrices.PriceID JOIN
Recipes ON RecipePrices.RecipeID = Recipes.RecipeID
END