Using SUM Instead of MSUM
The use of MSUM is discouraged. MSUM is a Teradata extension to the ANSI SQL:2011 standard, and is equivalent to the ANSI-compliant SUM window function. MSUM is retained only for backward compatibility with existing applications.
MSUM and Missing Data Points
Make sure that data you analyze using MSUM has no missing data points. Computing a moving average over data with missing points produces unexpected and incorrect results because the computation considers n physical rows of data rather than n logical data points.
Computing MSUM When Number of Rows is Less Than width
For data having fewer than width rows, MSUM computes the sum using all the preceding rows. MSUM returns the current sum rather than nulls when the number of rows in the sample is fewer than width.
Possible MSUM Result Overflow with SELECT Sum
When using this function, the result can create an overflow when the data type and format are not in sync. For a column defined as:
Salary Decimal(15,2) Format ‘$ZZZ,ZZ9.99’
The following query:
SELECT SUM (Salary) FROM Employee;
causes an overflow because the decimal operand and the format are not in sync.
To avoid possible overflows, explicitly specify the format for decimal sum to specify a format large enough to accommodate the decimal sum resultant data type.
SELECT Sum(Salary) (format ‘$Z,ZZZ,ZZZ,ZZ9.99) FROM Employee;