You are here

Teradata Sum

Submitted by Asif Nowaj, Last Modified on 2019-12-19

Teradata sum returns a column value that is the arithmetic sum of value_expression.


SUM([TYPE] 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.

teradata sum

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.

   FROM Inventory;


   Sum((QUANTITY * Price))

Discussion or Comment

If you have anything in mind to share, please bring it in the discussion forum here.