16.20 - Example: Group Sum - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
March 2019
Content Type
Programming Reference
Publication ID
B035-1145-162K
Language
English (United States)

The query below finds the total sum of meat sales for each city.

   SELECT city, kind, sales,
   SUM(sales) OVER (PARTITION BY city ROWS BETWEEN UNBOUNDED PRECEDING
   AND UNBOUNDED FOLLOWING) FROM monthly;

The possible results of the preceding SELECT appear in the following table.

city kind sales Group Sum (sales)
Omaha pure pork 45 220
Omaha pure pork 125 220
Omaha pure pork 25 220
Omaha variety pack 25 220
Chicago variety pack 55 175
Chicago variety pack 45 175
Chicago pure pork 50 175
Chicago variety pack 25 175