17.10 - Example: AS OF Queries on an ANSI Valid-Time Table - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - ANSI Temporal Table Support

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1186-171K
Language
English (United States)

The following AS OF query retrieves all table rows that were valid at 2002-01-01.

SELECT * 
FROM employee_vt 
FOR VALIDTIME AS OF DATE’2002-01-01’;

 eid ename terms  job_start     job_end
---- ----- ----- ---------- -----------
1001 Sania  TW08 2002/01/01  2006/12/31
1004 Fred   PW12 2001/05/01  9999/12/31

Only Sania and Fred had jobs with valid-time periods that include 2002-01-01.

Temporal queries can specify times in the future to return the rows that will be, or will still be valid at a future time:

SELECT * 
FROM employee_vt 
FOR VALIDTIME AS OF DATE’2015-02-01’;

 eid ename terms  job_start     job_end
---- ----- ----- ---------- -----------
1005 Alice  PW11 2005/12/01  9999/12/31
1010 Mike   TW07 2015/01/01  2016/12/31
1004 Fred   PW12 2001/05/01  9999/12/31