SELECT EMPLOYEE_ID,
  LEAVE_ID,
  RESULT_DAYS,
  ACTUAL_DAYS,
  (
  CASE
    WHEN RESULT_DAYS = ACTUAL_DAYS
    THEN 'PASSED'
    ELSE 'FALSE'
  END) AS TEST
FROM
  (SELECT RESULT.EMPLOYEE_ID,
    RESULT.LEAVE_ID,
    RESULT.DAYS AS RESULT_DAYS,
    ACTUAL.DAYS AS ACTUAL_DAYS
  FROM
    (SELECT R.EMPLOYEE_ID,
      R.LEAVE_ID,
      (R.TOTAL_DAYS-R.BALANCE) AS DAYS
    FROM HRIS_EMPLOYEE_LEAVE_ASSIGN R
    ) RESULT
  JOIN
    (SELECT A.EMPLOYEE_ID,
      A.LEAVE_ID,
      SUM(A.NO_OF_DAYS) AS DAYS
    FROM HRIS_EMPLOYEE_LEAVE_REQUEST A,
      (SELECT *
      FROM HRIS_MONTH_CODE
      WHERE TRUNC(SYSDATE) BETWEEN FROM_DATE AND TO_DATE
      ) M
    WHERE A.STATUS = 'AP'
    AND (A.START_DATE BETWEEN M.FROM_DATE AND M.TO_DATE)
    AND A.LEAVE_ID IN
      (SELECT LEAVE_ID FROM HRIS_LEAVE_MASTER_SETUP WHERE IS_MONTHLY ='Y'
      )
    GROUP BY A.EMPLOYEE_ID,
      A.LEAVE_ID
    ) ACTUAL
  ON (RESULT.EMPLOYEE_ID=ACTUAL.EMPLOYEE_ID
  AND RESULT.LEAVE_ID   = ACTUAL.LEAVE_ID)
  );