DbServer.Sum Method | |
Calculate the sum of a series of numeric expressions.
Namespace:
VO
Assembly:
VORDDClasses (in VORDDClasses.dll) Version: 2.21
Syntax VIRTUAL METHOD Sum(
acbExpression,
cbForBlock,
cbWhileBlock,
uScope
) AS USUAL CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public virtual Usual Sum(
Usual acbExpression = default,
Usual cbForBlock = default,
Usual cbWhileBlock = default,
Usual uScope = default
)
Request Example
View SourceParameters
- acbExpression (Optional)
- Type: Usual
The single expression that Sum() operates on or the array of expressions that Sum() operates on. - cbForBlock (Optional)
- Type: Usual
The condition evaluated for each record in the scope; if TRUE, the record is included in the processing. It provides the same functionality as the FOR clause of record processing commands. - cbWhileBlock (Optional)
- Type: Usual
The condition evaluated for each record from the first record until the condition returns FALSE. It provides the same functionality as the WHILE clause of record processing commands. - uScope (Optional)
- Type: Usual
The range of records to process, providing the same functionality as the ALL, REST and NEXT clauses of record processing commands.
Constant | Description |
---|
DBSCOPEALL |
The scope is all the records in the table. This is the default, although if a WHILE condition is specified, the scope becomes DBSCOPEREST.
|
DBSCOPEREST | The scope is the remaining records in the table from the current position. |
Return Value
Type:
Usual
An array that contains the sums for each expression or field specified.
Remarks
Sends a NotifyIntentToMove message before the operation.
On successful completion, the current record will be the last file record and DBServer:EOF will be TRUE.
Examples
The following example calculates the totals of the salaries, commissions, and withholdings for department 1348:
1aSums := oDB1:Sum({#Salary, #Commission, #Withholdings},{||Department=1348})
2? "Salary:", aSums[1]
3? "Commission:", aSums[2]
4? "Withholdings:", aSums[3]
See Also