17.10 - Option 2: Replace Missing Values with a Constant Value - 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)

You can use the UPDATE statement to update all rows with a missing value to a constant value. The example shows this for the TEMPERATURE column in Table and Data Definition for Time Series Aggregates Examples.

In the example, all null values are set to have a value of 50:

UPDATE OCEAN_BUOYS SET TEMPERATURE=50 WHERE TEMPERATURE IS NULL;

The example shows a query that performs an AVERAGE after setting the null values to a constant:

SELECT $TD_TIMECODE_RANGE, $TD_GROUP_BY_TIME, BUOYID, AVG(TEMPERATURE), COUNT(*)
FROM OCEAN_BUOYS
WHERE TD_TIMECODE BETWEEN TIMESTAMP '2014-01-06 08:00:00' AND TIMESTAMP '2014-01-06 10:30:00'
AND BUOYID=0
GROUP BY TIME (MINUTES(10) AND BUOYID)
ORDER BY 2,3;

Result: Note the Average in the first row has been affected.

TIMECODE_RANGE GROUP BY TIME(MINUTES(10)) BUOYID Average(TEMPERATURE) COUNT(*)
('2014-01-06 08:00:00.000000+00:00', '2014-01-06 08:10:00.000000+00:00') 1 0 53 3
('2014-01-06 08:10:00.000000+00:00', '2014-01-06 08:20:00.000000+00:00') 2 0 55 2