17.10 - Example - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Date and Time Functions and Expressions

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

Assume that in the employee1 table, created by the following CREATE TABLE statement, period1 and period2 are PERIOD (DATE) columns.

CREATE TABLE employee1 (
       eid INTEGER NOT NULL,
       name VARCHAR(100) NOT NULL,
       deptno INTEGER NOT NULL,
       period1(date),
       period2(date)
   ) PRIMARY INDEX(eid);
EID Name DeptNo Period 1 Period 2
1 Adams 101 ('2005-02-03', '2006-02-03') ('2005-02-03', '2006-02-03')
2 Mary 201 ('2005-04-02', '2006-01-03') ('2006-01-03', '2007-02-03')
3 Jones 301 ('2004-01-02', '2005-03-05') ('2003-03-05', '2004-01-02')

In the following SQL statement, EQUALS is used with period columns of the employee1 table:

SELECT eid, name, depno, period1, period2 
FROM employee1 
WHERE period1 EQUALS period2;

The result is:

EID Name DeptNo Period 1 Period 2
1 Adams 101 ('2005-02-03', '2006-02-03') ('2005-02-03', '2006-02-03')