Icon RUNSUM

Returns the running sum of a given numeric or interval expression for all selected rows.

Syntax
RUNSUM([DISTINCT] <NumericExpression>|<IntervalExpression>)

<NumericExpression> =

Type of:

SMALLINT
INTEGER|INT
BIGINT
FLOAT
DECIMAL|NUMERIC

<IntervalExpression> =

Type of:

INTERVAL YEAR
INTERVAL YEAR TO MONTH
INTERVAL MONTH
INTERVAL DAY
INTERVAL DAY TO HOUR
INTERVAL DAY TO MINUTE
INTERVAL DAY TO SECOND
INTERVAL DAY TO MSECOND
INTERVAL HOUR
INTERVAL HOUR TO MINUTE
INTERVAL HOUR TO SECOND
INTERVAL HOUR TO MSECOND
INTERVAL MINUTE
INTERVAL MINUTE TO SECOND
INTERVAL MINUTE TO MSECOND
INTERVAL SECOND
INTERVAL SECOND TO MSECOND
INTERVAL MSECOND

Returns
Same as input, except for the following types:

A SMALLINT expression is promoted to an INTEGER
An INTEGER expression is promoted to a BIGINT

This is done to prevent numeric overflows

Usage
The RUNSUM function returns the running sum of a given numeric or interval expression for all selected rows. The selected rows can be grouped into logical sub-sets by using the GROUP BY clause of the SELECT statement. Any time the numeric or interval expression is NULL, it is excluded from the running sum calculation.

Use the DISTINCT clause to specify that the running sum calculation will only use distinct values when calculating the result.

Examples
SELECT Month,
RUNSUM(Amount) AS RunningTotal
FROM TransactionHistory
GROUP BY Month

SQL 2003 Standard Deviations
This function deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis function is an ElevateDB extension.
Image