GROUP BY and Teradata-Specific Functions - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

For Teradata-specific functions, GROUP BY determines the partitions over which the function executes. The clause does not collapse all rows with the same value for the group-by columns into a single row. Thus, the GROUP BY clause in these cases need only specify the partitioning column for the function.

For example, the following statement computes the running sales for each store by using the GROUP BY clause to partition the data in sales_tbl by StoreID:

   SELECT StoreID, Sales, CSUM(Sales, StoreID)
   FROM sales_tbl 
   GROUP BY StoreID;

The results look like this:

   StoreID     Sales  CSum(Sales,StoreID)
   -------  --------  -------------------
      1001   1100.00              1100.00
      1001    400.00              1500.00
      1001   1000.00              2500.00
      1001   2000.00              4500.00
      1002    500.00               500.00
      1002   1500.00              2000.00
      1002   2500.00              4500.00
      1003   1000.00              1000.00
      1003   3000.00              4000.00