RUNNING_TOTAL
Description
RUNNING_TOTAL
sums up all entries of a given column and returns all intermediate sums. It can be applied to INT or FLOAT columns.
RUNNING_TOTAL
sums up all entries of a given column, but instead of aggregating all values into a single total result, it returns all intermediate sums. RUNNING_TOTAL
starts the summation at the top of the given input, respecting filtering and sorting.
Syntax
RUNNING_TOTAL ( table.column )
NULL handling
RUNNING_TOTAL
returns NULL for all NULL values at the beginning of the column. After the first value that is not NULL was added to the sum, the current intermediate sum is returned on NULL values.
Tip
To specify sorting columns inside the function directly, RUNNING_SUM can be used. RUNNING_SUM
also supports partitioning of the input.
Use Cases
RUNNING_TOTAL
can be used for Filling Ranges.
Examples
[1] Simple example for Running Total. | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
|
[2] Simple example for Running Total with null values. | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
|
[3] Simple example for Running Total. A FILTER is applied, such that only rows with an INCOME value less than 400 are taken into account. | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
|
[4] Running Total can also be performed on results of an aggregation. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
|