SELECT CASE
WHEN :p_date_start > paa.date_start THEN :p_date_start
WHEN :p_date_start < paa.date_start THEN paa.date_start
WHEN :p_date_start = paa.date_start THEN :p_date_start
END
start_date,
CASE
WHEN :p_date_end > paa.date_end THEN paa.date_end
WHEN :p_date_end < paa.date_end THEN :p_date_end
WHEN :p_date_end = paa.date_end THEN :p_date_end
END
end_date
FROM per_absence_attendances paa,
per_absence_attendance_types paat,
per_all_assignments_f paaf
WHERE paat.absence_attendance_type_id = paa.absence_attendance_type_id
AND UPPER (paat.name) = UPPER (:p_leave_type)
AND ( paa.date_start BETWEEN :p_date_start AND :p_date_end
OR paa.date_end BETWEEN :p_date_start AND :p_date_end
OR :p_date_start BETWEEN paa.date_start AND paa.date_end
OR :p_date_end BETWEEN paa.date_start AND paa.date_end)
AND paaf.person_id = paa.person_id
AND paaf.primary_flag = 'Y'
AND paaf.assignment_type = 'E'
AND paaf.assignment_status_type_id IN (1, 2)
AND :p_date_end BETWEEN paaf.effective_start_date
AND paaf.effective_end_date
AND paaf.assignment_id = :p_assignment_id
No comments:
Post a Comment