RUNNING_SUM
Applies to: CELONIS 4.7
Description
RUNNING_SUM returns the Sum of the previous rows. It is possible to specify a column based ordering and partitioning. Null values are skipped.
Syntax
RUNNING_SUM ( column [, ORDER BY ( sort_column [sorting], ... )] [, PARTITION BY ( partition_column, ... )] )
ASC: Ascending order
DESC: Descending order
column: The source column where preceding rows are taken from.
sort_column: Optional sorting column to specify an order.
sorting: Each of these columns can have an optional tag specifying the ordering of the column. Default is ascending:
partition_column: Optional partition column to specify groups in which
LAG
should operate.
Ordering
One or more columns can be given to specify an ordering. This tells the RUNNING_SUM
function what the preceding element actually is. Optionally every column can be tagged as ascending or descending.
Partitioning
The partition columns specify groups. The RUNNING_SUM
function operates independently within every group. This means when an ordering is given it is applied within every group.
Null handling
The running_sum for a NULL value is the same value as the running_sum value for the last non-NULL value.
Examples
[1] Simple example for Running Sum with Integer. |
[2] Simple example for Running Sum with floats. |
[3] |
[4] |
[5] Simple example for Running Sum with null. |