Oracle8i SQL Reference
Release 2 (8.1.6)

A76989-01

Library

Product

Contents

Index

Prev Up Next

Functions, 117 of 121


VAR_SAMP

Syntax


For information on syntax and semantics, see "Analytic Functions".

Purpose

VAR_SAMP returns the sample variance of a set of numbers after discarding the nulls in this set. You can use it as both an aggregate and analytic function.

The expr is a number expression, and the function returns a value of type NUMBER. If the function is applied to an empty set, it returns null. The function makes the following calculation:

(SUM(expr2) - SUM(expr)2 / COUNT(expr)) / (COUNT(expr) - 1)

This function is similar to VARIANCE, except that given an input set of one element, VARIANCE returns 0 and VAR_SAMP returns null.

See Also:

"Aggregate Functions" 

Aggregate Example

The following example returns the sample variance of the salaries in the EMP table.

SELECT VAR_SAMP(sal) FROM emp;

VAR_SAMP(SAL)
-------------
   1398313.87

Analytic Example

See the example at "VAR_POP".


Prev Up Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index