Name

VAR_POP

Synopsis

Use VAR_POP to compute the population variance of a set of values.

SQL2003 Syntax

VAR_POP( numeric_expression )

DB2 and PostgreSQL

These platforms do not provide a function to compute population variance.

MySQL

Use the VARIANCE function, which in MySQL returns the population variance.

Oracle

Oracle supports the standard syntax and the following analytic syntax:

VAR_POP (numeric_expression) OVER (window_clause)

For an explanation of the window_clause, see the section later in this chapter titled Section 4.3.

SQL Server

Use the VARP function.

Example

The following example computes the population variance for the values 1, 2, and 3:

SELECT * FROM test;
         X
----------
         1
         2
         3
SELECT VAR_POP(x) FROM test;
VAR_POP(X)
----------
.666666667

Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.