-- -- Use the Specify Values for Template Parameters -- command (Ctrl-Shift-M) to fill in the parameter -- values below. -- -- This block of comments will not be included in -- the definition of the function. -- ================================================ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE FUNCTION DistinctRatioAi ( -- Add the parameters for the function here @attribute1 varchar(50) ) RETURNS REAL AS BEGIN DECLARE @DistinctRatioAi REAL; DECLARE @t1 INT; DECLARE @t2 INT; DECLARE @distinctAi REAL; DECLARE @nonNullAi REAL; EXEC @t1 = DistinctAi @attribute1; EXEC @t2 = NonNullAi @attribute1; SET @distinctAi = CAST(@t1 AS REAL); SET @nonNullAi = CAST(@t2 AS REAL); SET @DistinctRatioAi = @distinctAi/@nonNullAi; RETURN @DistinctRatioAi; -- Add the SELECT statement with parameter references here --SELECT (a.DistinctAiAj / (MAX(b.DistinctAi, c.DistinctAi))) as SharedRatioAiAj --FROM DistinctAiAj(@attribute1, @attribute2) AS a, DistinctAi(@attribute1) AS b, DistinctAi(@attribute2) AS c END; GO