Average of Minimums - 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 two example queries show the average of nested minimums. In the first query, the table is a PTI table and the second example shows a non-PTI table:

/*PTI Table*/
SELECT AVG(TEMP_MIN) FROM (
    SELECT MIN(TEMPERATURE) AS TEMP_MIN
    FROM OCEAN_BUOYS
    WHERE TD_TIMECODE BETWEEN TIMESTAMP '2014-01-06 08:00:00' AND TIMESTAMP '2014-01-06 10:30:00'
    GROUP BY TIME (MINUTES(10) AND BUOYID)
) AS NESTED_MIN_TABLE;


/*Non-PTI Table*/
SELECT AVG(TEMP_MIN) FROM (
    SELECT MIN(TEMPERATURE) AS TEMP_MIN
    FROM OCEAN_BUOYS_NONPTI
    WHERE TIMECODE BETWEEN TIMESTAMP '2014-01-06 08:00:00' AND TIMESTAMP '2014-01-06 10:30:00'
    GROUP BY TIME (MINUTES(10) AND BUOYID)
    USING TIMECODE(TIMECODE)
) AS NESTED_MIN_TABLE;

The results get loaded into the derived table NESTED_MIN_TABLE. They are shown in ascending order, but this is not necessarily the expected order of the values in the derived table.

The results of both queries are identical, so only one result set is shown.
TEMP_MIN
10
10
43
43
70

Result: The actual result of the minimum of results (which are nested in the NESTED_MIN_TABLE):

Average(TEMP_MIN)
-----------------
35