17.00 - Examples: GROUP BY TIME with non-PTI Tables - Teradata Database

Teradata Vantageā„¢ - Time Series Tables and Operations

prodname
Advanced SQL Engine
Teradata Database
vrm_release
17.00
created_date
June 2020
category
Programming Reference
featnum
B035-1208-170K

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.