Tutorial 1, page 6 Context: jobsEngine: oracle

Did you notice that some empnos appeared more than once? This is because the jobhistory table contains information on both current and previous job positions for each employee. Each entry has a STARTDATE and ENDDATE. STARTDATE tell you when they started their job. If they have an ENDDATE, then they are finished their job. If the ENDDATE IS NULL then they are still in that job.

You can use ENDDATE IS NULL for entries without an ENDDATE, and ENDDATE IS NOT NULL for ones with an ENDDATE. The following lists salaries greater than 20000 for people still in that position.

  SELECT empno,salary
  FROM jobhistory
  WHERE salary >= 20000
  AND enddate IS NULL;

Adapt this code to list empno and salary for positions that have an ENDDATE which is not null, and where the salary is greater or equal to 20000.

Active SQL index Previous Question Next Question

SQL To Be Executed