16.20 - Supported Window Types for Aggregate UDFs - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Operators and User-Defined Functions

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
April 2020
Content Type
Administration
Programming Reference
Publication ID
B035-1210-162K
Language
English (United States)
Window Type Aggregation Group Supported Partitioning Strategy
Reporting window ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING Hash partitioning
Cumulative window
  • ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
  • ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
Hash partitioning
Moving window
  • ROWS BETWEEN value PRECEDING AND CURRENT ROW
  • ROWS BETWEEN CURRENT ROW AND value FOLLOWING
  • ROWS BETWEEN value PRECEDING AND value FOLLOWING
  • ROWS BETWEEN value PRECEDING AND value PRECEDING
  • ROWS BETWEEN value FOLLOWING AND value FOLLOWING
Hash partitioning and range partitioning

Consider the following table definition:

   CREATE TABLE t (id INTEGER, v INTEGER);

The following query specifies a reporting window of rows which the window aggregate UDF MYSUM operates on:

   SELECT id, v, MYSUM(v) OVER (PARTITION BY id ORDER BY v) 
   FROM t;

The following query specifies a cumulative window of rows which the window aggregate UDF MYSUM operates on:

   SELECT id, v, MYSUM(v) OVER (PARTITION BY id ORDER BY v 
                                ROWS UNBOUNDED PRECEDING) 
   FROM t;

The following query specifies a moving window of rows which the window aggregate UDF MYSUM operates on:

  SELECT id, v, MYSUM(v) OVER (PARTITION BY id ORDER BY v 
                               ROWS BETWEEN 2 PRECEDING AND 3 FOLLOWING)
  FROM t;