16.20 - About Aggregate Functions - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2020-03-25
dita:mapPath
xzf1512079057909.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
kby1472250656485

Aggregate functions are typically used in arithmetic expressions. Aggregate functions operate on a group of rows and return a single numeric value in the result table for each group.

In the following statement, the SUM aggregate function operates on the group of rows defined by the Sales_Table table:

   SELECT SUM(Total_Sales)
   FROM Sales_Table;
   Sum(Total_Sales)
   ----------------
            5192.40

You can use GROUP BY clauses to produce more complex, finer grained results in multiple result values. In the following statement, the SUM aggregate function operates on groups of rows defined by the Product_ID column in the Sales_Table table:

   SELECT Product_ID, SUM(Total_Sales)
   FROM Sales_Table
   GROUP BY Product_ID;
   Product_ID  Sum(Total_Sales)
   ----------  ----------------
          101           2100.00
          107           1000.40
          102           2092.00