Difference between revisions of "SUM"

From Recital Documentation Wiki
Jump to: navigation, search
(Products)
(Syntax)
 
Line 4: Line 4:
  
 
==Syntax==
 
==Syntax==
SUM [<scope>] [<expN1> [,<expN2>....]]
+
SUM [<scope>] <expN1> [,<expN2>....]
  
 
[TO <memvar list>][FOR <condition>]
 
[TO <memvar list>][FOR <condition>]
  
 
[WHILE <condition>]
 
[WHILE <condition>]
 
  
 
==See Also==
 
==See Also==

Latest revision as of 11:56, 7 March 2017

Purpose

Sum numeric expressions against records in the currently selected table


Syntax

SUM [<scope>] <expN1> [,<expN2>....]

[TO <memvar list>][FOR <condition>]

[WHILE <condition>]

See Also

AVERAGE, COUNT, REPORT, TOTAL


Description

The SUM command totals the specified numeric expressions with respect to the records in the currently selected table. If <scope> is not specified, then ALL is used, unless the WHILE clause is specified, in which case the <scope> will default to REST. Up to fifteen numeric expressions can be summed. You can specify different target memory variables, with comma separators, for storing the different expressions. If SET DELETED ON is in effect, then records that are marked for deletion will not be included in the calculations. If a FILTER <condition> is active, then only those records that satisfy the <condition> will be included in the calculations. If the target memory variables do not exist, then they will be automatically created.

TO <memvar list>

If the TO <memvar list> clause is not specified, then the results are displayed on the screen only if TALK is ON. If TALK is OFF, then a <memvar list> must be specified so that the results are accessible.

FOR <condition>

If a FOR <condition> is specified, then only those records which satisfy the <condition> are included in the calculations.

WHILE <condition>

The WHILE <condition> can be used in conjunction with the FIND or SEEK commands, and the REST <scope>, to restrict the number of records which are processed and therefore optimize the performance of the SUM command.

TO ARRAY <array>

The TO ARRAY clause is used to store the SUM results in a one-dimensional array. The result of the first numeric expression is placed in the first array element; the second result is placed in the second element, and so on. If there are fewer elements than expressions, the SUM command will only store results for which there are elements. If there are more elements than expressions, the remaining elements are left empty.


Example

use patrons
sum seats to m_seats;
  for event = "BALLET" and date = date()
? m_seats
      1680


Products

Recital Server, Recital