The SUM function returns the sum of a set of numbers.
The data type of the result is the same as the data type of the argument values except that the result is:
For information about the values of p, s, and mp, see Decimal arithmetic in SQL.
The function is applied to the set of values derived from the argument values by the elimination of null values. If DISTINCT is specified, duplicate values are eliminated.
The order in which the values are added is undefined, but every intermediate result must be within the range of the result data type.
Results involving DECFLOAT special
values: If the data type of the argument is decimal floating-point
and a special value of sNaN or -sNaN, or both +Infinity and -Infinity
are included in the aggregation, an error is signaled. Otherwise,
if +NaN or -NaN is found, the result is +NaN or -NaN. If +Infinity
or -Infinity is found, the result is +Infinity or -Infinity.
SELECT SUM(BONUS) INTO :JOB_BONUS FROM EMPLOYEE WHERE JOB = 'CLERK'Results in JOB_BONUS being set to 4000.