Teradata sum returns a column value that is the arithmetic sum of value_expression.
Where value_expression is a literal or column expression for which the Teradata sum is to be computed. The expression cannot contain any ordered analytical or aggregate functions.
[TYPE] is an optional parameter.
Where TYPE as ALL => that all non-null values specified by value_expression, including duplicates, are included in the sum computation for the group. This is the default.
Where TYPE as DISTINCT => that duplicate and non-null values specified by value_expression are eliminated from the sum computation for the group.
If you are looking for Teradata cumulative sum using partition by, please click the link.
Example of Teradata SUM: Accounts Receivable
You need to know how much cash you need to pay all vendors who billed you 30 or more days ago.
SELECT SUM(Invoice) FROM AcctsRec WHERE (CURRENT_DATE - InvDate) >= 30;
Example of Teradata SUM: Face Value of Inventory
You need to know the total face value for all items in your inventory.
SELECT SUM(QUANTITY * Price) FROM Inventory;
Sum((QUANTITY * Price)) ----------------------- 38,525,151.91