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: