IF EXISTS (SELECT *
FROM sysobjects
WHERE name = N'fn_avg')
DROP FUNCTION fn_avg
GO
CREATE FUNCTION fn_avg (@tbl as CHAR , @dte1 as datetime , @sum_fld as char, @id_fld as char)
RETURNS money
AS
BEGIN
return (select avg(@sum_fld) as ddd from @tbl where @id_fld <= @dte1 )
END
GO
IF EXISTS (SELECT *
FROM sysobjects
WHERE name = N'fn_avg')
DROP FUNCTION fn_avg
GO
CREATE FUNCTION fn_avg (@tbl as CHAR(30) , @dte1 as datetime , @sum_fld as char(30), @id_fld as char(30))
RETURNS money
AS
BEGIN
return (select avg(@sum_fld) as ddd from @tbl where @id_fld <= @dte1 )
END
GO