用SQL Server HAVING子句计算列和平均值

开发者在线 Builder.com.cn 更新时间:2007-01-30作者:builder.com.cn 来源:

CREATE FUNCTION [dbo].[AverageSale_fns] 
(
      -- Add the parameters for the function here
      -- 
)
RETURNS money
AS
BEGIN
      -- Declare the return variable here
      DECLARE @Result money

      -- Add the T-SQL statements to compute the return value here
      SET @Result =(SELECTAvg(TotalSale)AS AverageSale
      FROM dbo.SalesTotals_fnt())

      -- Return the result of the function
      RETURN @Result

END

用户评论

  • 用户名
  • 评论内容