16.20 - Example: Group Sum - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Functions, Expressions, and Predicates

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
created_date
March 2019
category
Programming Reference
featnum
B035-1145-162K

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