Export (0) Print
Expand All

VARP (Transact-SQL)

Returns the statistical variance for the population for all values in the specified expression.

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.

Topic link icon Transact-SQL Syntax Conventions

VARP ( [ ALL | DISTINCT ] expression )
   OVER ( [ partition_by_clause ] order_by_clause )  nh

ALL

Applies the function to all values. ALL is the default.

DISTINCT

Specifies that each unique value is considered.

expression

Is an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.

OVER ( [ partition_by_clause ] order_by_clause)

partition_by_clause divides the result set produced by the FROM clause into partitions to which the function is applied. If not specified, the function treats all rows of the query result set as a single group. order_by_clause determines the logical order in which the operation is performed. order_by_clause is required. For more information, see OVER Clause (Transact-SQL).

If VARP is used on all items in a SELECT statement, each value in the result set is included in the calculation. VARP can be used with numeric columns only. Null values are ignored.

VARP is a deterministic function when used without the OVER and ORDER BY clauses. It is nondeterministic when specified with the OVER and ORDER BY clauses. For more information, see Deterministic and Nondeterministic Functions.

The following example returns the variance for the population for all bonus values in the SalesPerson table in the AdventureWorks2012 database.

SELECT VARP(Bonus)
FROM Sales.SalesPerson;
GO

Community Additions

ADD
Show:
© 2014 Microsoft