SQL Server Statistical Functions – VAR, VARP, STDEV, STDEVP

SQL Server offers the following statistical functions.

VAR Returns the statistical variance of all values in the specified expression.
VARP Returns the statistical variance for the population for all values in the specified expression
STDEV Returns the statistical standard deviation of all values in the specified expression
STDEVP Returns the statistical standard deviation for the population for all values in the specified expression

All these functions return float.

The OVER clause may follow all aggregate functions except CHECKSUM.

Here is another sample to explain the relationships between SQL Server statistic functions:

USE AdventureWorks;
GO

SELECT
  STDEVP(Bonus)
  ‘Standard Deviation for the Population’,

  STDEV(Bonus)
  ‘Standard Deviation’,

  VAR(Bonus)
  ‘Variance’,

  STDEV(Bonus) * STDEV(Bonus)
  ‘VAR via STDEV’,

  VARP(Bonus)
  ‘Variance for the Population’,

  STDEVP(Bonus) * STDEVP(Bonus)
  ‘VARP via STDEVP’,

  VAR(Bonus) * (COUNT(Bonus)-1) / COUNT(Bonus)
  ‘VARP via VAR‘

FROM Sales.SalesPerson;
GO
Advertisements
Published in: on February 16, 2012 at 4:40 am  Leave a Comment  
Tags: , , , ,

The URI to TrackBack this entry is: https://blackbeltreview.wordpress.com/2012/02/16/sql-server-statistical-functions-var-varp-stdev-stdevp/trackback/

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: