
// CF 7-13

// Incumbents table

CREATE TABLE Incumbents (
                        SSN             integer,
                        PCN             integer,
                        StartDate       date,
                        EndDate         date,
                        PRIMARY KEY (SSN, PCN)
                        );

// Actual insert

INSERT INTO Incumbents
  SELECT 111223333,
         341288,
         DATE '01/01/1997',
         DATE '01/01/1998'
    FROM Incumbents
   WHERE NOT EXISTS (SELECT *
                       FROM Incumbents AS I2
                      WHERE Incumbents.SSN = I2.SSN
                        AND I2.StartDate < DATE '01/01/1998'
                        AND DATE '01/01/1997' < I2.EndDate);

