Table of Contents

Search

  1. Preface
  2. Function reference
  3. Constants
  4. Operators
  5. Dates
  6. Functions
  7. System variables
  8. Datatype reference

Function Reference

Function Reference

CUME

CUME

Returns a running total. A running total means CUME returns a total each time it adds a value. You can add a condition to filter rows out of the row set before calculating the running total.
Use CUME and similar functions, such as MOVINGAVG and MOVINGSUM, to simplify reporting by calculating running values.

Syntax

CUME(
numeric_value
[,
filter_condition
] )
Argument
Required/
Optional
Description
numeric_value
Required
Numeric datatype. Passes the values for which you want to calculate a running total. You can enter any valid expression. You can create a nested expression to calculate a running total based on the results of the function as long as the result is a numeric value.
filter_condition
Optional
Limits the rows in the search. The filter condition must be a numeric value or evaluate to TRUE, FALSE, or NULL. You can enter any valid expression.

Return Value

Numeric value.
NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

Nulls

If a value is NULL, CUME returns the running total for the previous row. However, if all values in the selected column are NULL, CUME returns NULL.

Examples

The following example returns the running total of the PERSONAL_SALES column:
CUME( PERSONAL_SALES )
PERSONAL_SALES
RETURN VALUE
40000
40000
80000
120000
40000
160000
60000
220000
NULL
220000
50000
270000
Likewise, you can add values before calculating a running total:
CUME( CA_SALES + OR_SALES )
CA_SALES
OR_SALES
RETURN VALUE
40000
10000
50000
80000
50000
180000
40000
2000
222000
60000
NULL
222000
NULL
NULL
222000
50000
3000
275000

0 COMMENTS

We’d like to hear from you!