RDD

DbSum()

Sum an expression over a record scope

Syntax

Signature
DbSum( bExpression, [bFor], [bWhile], [nNext], [nRecord], [lRest] ) --> nSum

Arguments

bExpression

Numeric expression block. Remaining arguments define the scope.

Return value

The sum of expression values in the selected records.

Description

DbSum() evaluates bExpression for records in the current work area and adds the numeric results.

Notes

An empty scope returns zero.

Example

DbSum.prg
PROCEDURE Main()

   DbUseArea( .T., , "sales.dbf", "Sales" )
   QOut( "Sum: " + LTrim( Str( DbSum( {|| FIELD->AMOUNT } ) ) ) )
   DbCloseArea()

RETURN

Output

See also