Returns the statistical variance of all values in the specified expression. May be followed by the OVER clause.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.
If VAR is used on all items in a SELECT statement, each value in the result set is included in the calculation. VAR can be used with numeric columns only. Null values are ignored.
VAR 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 all bonus values in the SalesPerson table in the AdventureWorks2012 database.
SELECT VAR(Bonus) FROM Sales.SalesPerson; GO