running-difference
Returns a running difference by row, calculated as the difference between the value for the current row and the preceding row, (including the current row) for a set of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources.
Syntax
running-difference ( numeric_expression [ at expression { ,
expression } ] [ <for-option> ] [ prefilter ] )
running-difference ( numeric_expression [ <for-option> ]
[ prefilter ] )
<for-option> ::= for expression { , expression }|for report|auto
Example
running-difference ( Qty )
Result
For each row, returns the quantity and a running difference between the value for the current row and the preceding row.
Result data
Name | Qty | Running-Difference for name |
---|---|---|
Smith | 7 | NULL |
Smith | 3 | -4 |
Smith | 6 | 3 |
Smith | 4 | -2 |
Wong | 3 | -1 |
Wong | 5 | 2 |