17.10 - Examples: GROUP BY TIME with non-PTI Tables - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - Time Series Tables and Operations

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1208-171K
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.