Example

Teradata Vantageā„¢ SQL Functions, Expressions, and Predicates

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

This example finds cumulative sales for all periods of increasing sales for each region.

   SUM(sales) OVER (
        PARTITION BY region
        ORDER BY day_of_calendar
        RESET WHEN sales < /* preceding row */ SUM(sales) OVER (
             PARTITION BY region
             ORDER BY day_of_calendar
             ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
        ROWS UNBOUNDED PRECEDING
   )