CREATE TABLE past_emp
(
  lastname VARCHAR2(20),
  firstname VARCHAR2(20),
  hiredate DATE,
  leavedate DATE,
  years_employed AS (TRUNC(MONTHS_BETWEEN(leavedate, hiredate) / 12))
)
/

INSERT INTO past_emp (lastname, firstname, hiredate, leavedate)
VALUES ('Smith', 'John', '14-FEB-1999', '29-OCT-2006')
/

INSERT INTO past_emp (lastname, firstname, hiredate, leavedate)
VALUES ('Smith', 'Betty', '12-SEP-1990', '06-JAN-1995')
/

SELECT years_employed
  FROM past_emp
 WHERE lastname = 'Smith'
/
