VARIANCE
VARIANCE is a statistical SQL function used to determine the variance of a particular set of values within a specified column in the database. It measures how spread out the numbers in the data set are. If the return value is high, the numbers are very spread out; if it is low, the numbers are close to the mean.
VARIANCE( expr )
- expr: This is the column or expression for which the variance is to be calculated. The `expr` must be a number type field.
Example
Output
Explanation
In the example, the function VARIANCE()
is used to compute the statistical variance of all salaries in the employees
table. The variance quantifies the spread of the salary data. The higher the variance, the wider the range of salaries in the company.
VARIANCE( expression )
- expression: This is the numeric expression over which the variance will be calculated. It represents any valid expression that resolves to a number from which the variance needs to be derived. This can refer to a column of a table, or a mathematical expression involving numbers and column values.
Example
Output
Explanation
The example code calculates the variance of salaries for all employees in the ‘Employees’ table. The VARIANCE() function calculates the variance of a set of numbers. The variance measures how far each number in the set is from the mean (average) and thus from every other number in the set. Here it is used to understand the dispersion of employee salaries.