Definition:

The Oracle VARIANCE function returns the variance or *variability* of an expression. In other words, VARIANCE computes how much a set of numbers varies or differs within the set. You can use VARIANCE as an aggregate or analytic function.

The Oracle Database calculates the variance of the expression as follows:

As 0 if the number of rows in expr = 1

As VAR_SAMP if the number of rows in expr > 1

The Oracle VARIANCE, VAR_POP and VAR_SAMP functions are directly related to their standard deviation counterparts, as standard deviation is simply the square root of the variance. STDDEV and VARIANCE are similar in what they return if there is only one element (both will return a zero).

**Example Syntax:**

VARIANCE([DISTINCT | ALL] <value>) OVER (<analytic_clause>)

**Example Usage:**

SELECT last_name, salary,

VARIANCE(salary) OVER (ORDER BY hire_date) AS VARIANCE

FROM employees

WHERE department_id = 30;

Related Links:

Related Code Snippets:

- VARIANCE - VARIANCE returns the variance of expr. You can use it as an aggregate or analytic funct...