Assume that in 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, IMMEDIATELY SUCCEEDS is used with period columns of the employee1 table:
SELECT eid, name, deptno, period1, period2 FROM employee1 WHERE period1 IMMEDIATELY SUCCEEDS period2;
The result is:
EID | Name | DeptNo | Period 1 | Period 2 |
---|---|---|---|---|
3 | Jones | 301 | ('2004-01-02', '2005-03-05') | ('2003-03-05', '2004-01-02') |