SUM
Sum numeric expressions and assign results to variables
Syntax
SUM <nExp list> TO <idVar list> [<scope>] [WHILE <lCondition>] [FOR <lCondition>]
Arguments
<nExp list> is the list of numeric values to sum for each record processed.
TO <idVar list> identifies the receiving variables to be assigned assign the results of the sum. Variables that either do not exist or are not visible are created as private variables. <idVar list> must contain the same number of elements as <nExp list>.
<scope> is the portion of the current database file to SUM. The default scope is ALL records.
WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails.
FOR <lCondition> specifies the conditional set of records to SUM within the given scope.
Description
SUM is a database command that totals a series of numeric expressions for a range of records in the current work area and assigns the results to a series of variables. The variables specified in <idVar list> can be field, local, private, public, or static.
Note that the <nExp list> is required and not optional as it is in other dialects.
Examples
. This example illustrates the use of SUM: LOCAL nTotalPrice, nTotalAmount USE Sales NEW SUM Price * .10, Amount TO nTotalPrice, nTotalAmount // ? nTotalPrice // Result: 151515.00 ? nTotalAmount // Result: 150675.00
Seealso
AVERAGE, DBEVAL(), TOTAL