From Lianjapedia
Jump to: navigation, search


Sum numeric expressions against records in the currently selected table


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

TO <memvar list> | to ARRAY <array>

[FOR <condition>]

[WHILE <condition>]

See Also



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. 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.

TO <memvar list>

If the TO <memvar list> clause is specified, then the results are stored to the memory variables in the comma-separated <memvar list>. If the target memory variables do not exist, then they will be automatically created.

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. The array must be pre-declared.

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.


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