xHarbour Reference Documentation > Command Reference |
Calculates the sum of numeric expressions in the current work area.
SUM <expressions,...> ; TO <resultVarNames,...> ; [<Scope>] ; [WHILE <lWhileCondition>] ; [FOR <lForCondition>]
The SUM command is used to calculate sum 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 explicitly defining a scope.
Records marked for deletion are not included in the calculation when SET DELETED is set to ON.
See also: | AVERAGE, DbEval(), TOTAL |
Category: | Database commands |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example adds daily sales for the month of December. PROCEDURE Main LOCAL nSales := 0 USE Invoice SUM FIELD->Total TO nSales FOR ; Month(PayDate) == 12 .AND. Year(PayDate)=Year(Date()) ? "December sales:", nSales CLOSE Invoice RETURN
http://www.xHarbour.com