GROUP BY TIME and Subqueries Examples | Teradata Vantage - Examples: GROUP BY TIME and Subqueries - Analytics Database - Teradata Vantage

Time Series Tables and Operations

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-10-30
dita:mapPath
tuc1628112453431.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
sfz1493079039055
lifecycle
latest
Product Category
Teradata Vantageā„¢

The rules and restrictions for inferring the timecode are per query, so if there are subqueries you may need to specify the USING TIMECODE clause. For more information on GROUP BY TIME rules and restrictions, see Usage Notes and for the rules and restrictions on USING TIMECODE see Usage Notes.

Example: GROUP BY TIME with Subqueries

In the example, the timecode is inferred in the inner subquery and the outer query specifies the USING TIMECODE clause:

sel avg(temperature) as a
from non_pti_tbl_seq
group by time(minutes(10))
using timecode(timecode)
having a IN ( sel count(*)
    from ocean_buoys
    group by time(minutes(1)) );

Example: Invalid GROUP BY TIME with Subqueries

In the example, the timecode is inferred in the inner subquery but not in the outer query, so an error is reported:

sel avg(temperature) as a
from non_pti_tbl_seq
group by time(minutes(10))
having a IN ( sel count(*)
    from ocean_buoys
    group by time(minutes(1)) );

Result:

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