SQL VARP Function

VARP returns the statistical variance for the population of the given values.

This funcion ignores NULL values.

Use VARP if the given values represent the entire population.

Use VAR if the given values represent a sample.

Example

#

This example return the variance for the population of all sales.

SELECT VARP(TotalAmount) AS 'Variance'
  FROM [Order]
Result:  1 record
Variance
3957769.80164355

Syntax

Syntax of the VARP function.

VARP(value)

value -- a number or numeric column.

More Examples

VARP with GROUP BY

PRODUCT
Id
ProductName
SupplierId
UnitPrice
Package
IsDiscontinued
SUPPLIER
Id
CompanyName
ContactName
City
Country
Phone
Fax
Problem: List suppliers with the statistical variance for the population of their product prices.
SELECT S.CompanyName, 
       VARP(UnitPrice) AS 'Price Variance'
  FROM Product P
  JOIN Supplier S ON S.Id = P.SupplierId
 GROUP BY S.CompanyName
Result:  29 records
CompanyName Price Variance
Aux joyeux ecclésiastiques 15067.5625
Bigfoot Breweries 3.55555555555554
Cooperativa de Quesos 'Las Cabras' 72.25
Escargots Nouveaux 0
Exotic Liquids 16.2222222222222

Note: A value of 0 is returned when a supplier only has 1 product.


You may also like



Guides


vsn 3.1