16.20 - Examples: GROUP BY TIME with non-PTI Tables - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ Time Series Tables and Operations

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

Because GROUP BY TIME queries can be used with non-PTI tables, the USING TIMECODE clause provides a way to specify the timecode to use. If the USING TIMECODE clause is not specified when there are no PTI tables to infer a timecode from, an error is reported.

Example: GROUP BY TIME and USING TIMECODE with non-PTI Table

A non-PTI table does not have a primary time index, so specify the timecode explicitly with the USING TIMECODE clause:

select avg(temperature)
from non_pti_tbl_seq
group by time(minutes(10))
using timecode(timecode);

Example: Invalid GROUP BY TIME with non-PTI Table

A non-PTI table does not have a primary time index, so if the USING TIMECODE clause is omitted an error is reported:

select avg(temperature)
from non_pti_tbl_seq
group by time(minutes(10));

*** Failure 4359 Time Series: GROUP BY TIME clause may not be used without a TIMECODE specification.