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/(
      CASE
        WHEN A.HALF_DAY IN ('F','S')
        THEN 2
        ELSE 1
      END)) AS DAYS
    FROM HRIS_EMPLOYEE_LEAVE_REQUEST A
    WHERE A.STATUS = 'AP'
    GROUP BY A.EMPLOYEE_ID,
      A.LEAVE_ID
    ) ACTUAL
  ON (RESULT.EMPLOYEE_ID=ACTUAL.EMPLOYEE_ID
  AND RESULT.LEAVE_ID   = ACTUAL.LEAVE_ID)
  )
WHERE LEAVE_ID NOT IN
  (SELECT LEAVE_ID FROM HRIS_LEAVE_MASTER_SETUP WHERE IS_MONTHLY ='Y'
  );