xHarbour Reference Documentation > Command Reference |
Calculates the average of numeric expressions in the current work area.
AVERAGE <expressions,...> ; TO <resultVarNames,...> ; [<Scope>] ; [WHILE <lWhileCondition>] ; [FOR <lForCondition>]
The AVERAGE command is used to calculate average values for one or more numeric expressions. The expressions are evaluated in the current work area. The number of records to include in the calculation can be restricted using a FOR and/or WHILE condition or by explicitely defining a scope.
See also: | COUNT, DbEval(), SUM, TOTAL |
Category: | Database commands |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// This example calculates the average payments for the first half // of this year: PROCEDURE Main LOCAL nAvg USE Sales NEW AVERAGE Payment TO nAvg FOR Month(SALEDATE) < 7 .AND. ; Year(SALEDATE) == Year(Date()) USE ? nAvg RETURN
http://www.xHarbour.com