Chapter 18 – Statistical Aggregate Functions

"You can make more friends in two months by becoming interested in other people than you will in two years by trying to get other people interested in you."

- Dale Carnegie

The Stats Table

image

Above is the Stats_Table data in which we will use in our statistical examples.

The VAR and VARP Functions

SELECT VAR(col1)   AS Variance_Example,

VARP(col1) AS Var_EntirePopulation

FROM   Stats_Table ;

Variance_Example

Var_EntirePopulation

77.5

74.92

The VAR and VARP functions return the statistical variance of all the values in the specified expression. The VAR uses a sample of the data population to return a value. The VARP returns the value based upon the entire data population. The expression parameter must be one of the exact or approximate numeric data types, except for the bit data type.

A VAR Example

image

A VARP Example

image

The STDEV and STDEVP Functions

SELECT STDEV(Col1)   AS StandDev

,STDEVP(Col1) AS StandDevPop

FROM   Stats_Table

StandDev

StandDevPop

8.8

8.66

image

The STDEV function returns the standard deviation of all the values in the specified expression, but only uses a sample of the data population to return a value. The STDEVP returns the standard deviation value based upon the entire data population. The expression parameter must be one of the exact or approximate numeric data types, except for the bit data type.

A STDEV Example

image

A STDEVP Example

image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset