
/* Code Fragment 5.11 Provide the salary and position history for all employees. */

SELECT S.SSN, AMOUNT, PCN, HISTORY_START_DATE, HISTORY_END_DATE
FROM SAL_HISTORY AS S, INCUMBENTS
WHERE S.SSN = INCUMBENTS.SSN
AND START_DATE < HISTORY_START_DATE
AND HISTORY_END_DATE <= END_DATE

UNION ALL

SELECT S.SSN, AMOUNT, PCN, HISTORY_START_DATE, END_DATE
FROM SAL_HISTORY AS S, INCUMBENTS
WHERE S.SSN = INCUMBENTS.SSN
AND HISTORY_START_DATE >= START_DATE
AND END_DATE < HISTORY_END_DATE
AND HISTORY_START_DATE < END_DATE

UNION ALL

SELECT S.SSN, AMOUNT, PCN, START_DATE, HISTORY_END_DATE
FROM SAL_HISTORY AS S, INCUMBENTS
WHERE S.SSN = INCUMBENTS.SSN
AND START_DATE > HISTORY_START_DATE
AND HISTORY_END_DATE <= END_DATE
AND START_DATE < HISTORY_END_DATE

UNION ALL

SELECT S.SSN, AMOUNT, PCN, START_DATE, END_DATE
FROM SAL_HISTORY AS S, INCUMBENTS
WHERE S.SSN = INCUMBENTS.SSN
AND START_DATE > HISTORY_START_DATE
AND END_DATE < HISTORY_END_DATE


