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

Time Series Tables and Operations

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
zzg1600277315070.ditamap
dita:ditavalPath
zzg1600277315070.ditaval
dita:id
B035-1208
lifecycle
previous
Product Category
Teradata Vantageā„¢

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.