Login    Register

XLeratorDB/statistics Documentation

GEOMEAN


 
Updated: 6 August 2010

Use GEOMEAN to calculate the geometric mean for a dataset containing positive numbers. The equation for geometric mean is:
 GEOMEAN
Syntax
SELECT [wctStatistics].[wct].[GEOMEAN] (
   <@Values_TableName, nvarchar(4000),>
 ,<@ColumnName, nvarchar(4000),>
 ,<@GroupedColumnName, nvarchar(4000),>
 ,<@GroupedColumnValue, sql_variant,>)
Arguments
 
@Values_TableName
the name, as text, of the table or view that contains the positive values to be used in the GEOMEAN calculation.
@ColumnName
the name, as text, of the column in the table or view specified by @Values_TableName that contains the positive values to be used in the GEOMEAN calculation.
@GroupedColumnName
the name, as text, of the column in the table or view specified by @Values_TableName which will be used for grouping the results.
@GroupedColumnValue
the column value to do the grouping on.
Return Types
float
Remarks
·         If any values in the dataset are less than or equal to zero, GEOMEAN will return an error.
·         No GROUP BY is required for this function even though it produces aggregated results.
Examples
CREATE TABLE #g1(
      [num] [float] NOT NULL
)
insert into #g1 Values (4.6)
insert into #g1 Values (5.7)
insert into #g1 Values (8.3)
insert into #g1 Values (7.29)
insert into #g1 Values (10.965)
insert into #g1 Values (4.166667)
insert into #g1 Values (3.14159265358979)
 
select wct.GEOMEAN('#g1','num','', NULL)


This produces the following result

----------------------
5.82560187538148
 
(1 row(s) affected)


  Comments
Add Comment
No Comments Yet


 |  View Topic History  |
Copyright 2010 WestClinTech LLC         Privacy Policy        Terms of Service