All Functions
WHERE Clause
HAVING Clause
GROUP BY Clause
FUNCTION: VAR
SELECT VAR(field) AS [expression]
FROM table
[WHERE ...]
[GROUPBY ...]
[HAVING ...]
The
VAR
function is one of the aggregate functions that are used to calculate statistical information for a specified numeric field in a query. The other aggregate functions are:
AVG, COUNT, MAX, MIN, STDEV, STDEVP, SUM, VARP
. Note that all of these functions return a single value.
The
VAR
function finds the variance by using a portion, called a sample, of the total number of values in a field. This is a time saver when dealing with extremely large tables and can be shown to be statistically valid. In comparison, the
VARP
function uses all of the values to calculate the variance. There must be at least two values in the field or the variance will not be calculated and a
NULL
is returned.
This code finds the variance of the age of the MediCare patients in a hospital (by using a sample) and stores that information in VarAge.
SELECT VAR(Age) AS [VarAge]
FROM MediCarePatients
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information