niisar
5/19/2014 - 9:34 PM

determine if an employee is earning the same salary as his/her manager.

determine if an employee is earning the same salary as his/her manager.

WITH RSFC(EMPID,ENAME,MGRID,LVL,SAL) AS
  (SELECT EMPLOYEE_ID,
    EMPLOYEE_NAME,
    MANAGER_ID,
    0 AS LVL,
    SALARY
  FROM COMPANY
  WHERE MANAGER_ID IS NULL
  UNION ALL
  SELECT EMPLOYEE_ID,
    EMPLOYEE_NAME,
    MANAGER_ID,
    LVL+1,
    SALARY
  FROM RSFC R
  INNER JOIN COMPANY F
  ON F.MANAGER_ID = R.EMPID
  ) cycle SAL
  SET IS_CYCLE TO 'Y' DEFAULT 'N'
SELECT * FROM RSFC