Updated: 6 August 2010
Use STDEVP to return the standard deviation for an entire population. The standard deviation is a measure of how widely values are dispersed from the mean. The equation for STDEVP is:
Syntax
SELECT [wctStatistics].[wct].[STDEVP] (
<@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 values to be used in the STDEVP calculation.
@ColumnName
the name, as text, of the column in the table or view specified by @TableName that contains the values to be used in the STDEVP calculation.
@GroupedColumnName
the name, as text, of the column in the table or view specified by @TableName which will be used for grouping the results.
@GroupedColumnValue
the column value to do the grouping on.
Return Types
float
Remarks
· If you want measure the standard deviation for a sample, then use the STDEV function.
· For more complex queries or for queries on normalized data, use the STDEVP_q function.
· No GROUP BY is required for this function even though it produces aggregated results.
Examples
CREATE TABLE #k1(
[num] [float] NOT NULL
)
INSERT INTO #k1 VALUES (91.3698)
INSERT INTO #k1 VALUES (76.3382)
INSERT INTO #k1 VALUES (74.5692)
INSERT INTO #k1 VALUES (85.2957)
INSERT INTO #k1 VALUES (99.0112)
INSERT INTO #k1 VALUES (86.99)
INSERT INTO #k1 VALUES (70.7837)
INSERT INTO #k1 VALUES (72.834)
INSERT INTO #k1 VALUES (78.1644)
INSERT INTO #k1 VALUES (77.7472)
INSERT INTO #k1 VALUES (66.0627)
INSERT INTO #k1 VALUES (59.781)
INSERT INTO #k1 VALUES (68.4793)
INSERT INTO #k1 VALUES (78.6103)
INSERT INTO #k1 VALUES (59.8621)
select wct.STDEVP('#k1','num','',NULL)
This produces the following result
----------------------
10.6563315803558
(1 row(s) affected)