I am trying provide an alternative to the calculation I have going in my case statement. Currently it is looking at 'close_date' in order to satisfy the equation. I want it to be able to look at 'close_date' first, but if it is null, then use SYSDATE.
My code is as follows:
SELECT CASE
WHEN fourthlevel.case_type IN
('Complaint')
THEN
(SELECT COUNT (*)
FROM work_days1
WHERE work_days1.business_date >
fourthlevel.correspond_date
AND work_days1.business_date <=
fourthlevel.close_date)
WHEN fourthlevel.case_type IN ('Enquiry')
THEN
(SELECT COUNT (*)
FROM work_days1
WHERE work_days1.business_date >
fourthlevel.create_date
AND work_days1.business_date <=
fourthlevel.close_date)
END
AS sla_days
FROM fourthlevel
So do I use a nested if-else statement in my where clauses, or another case statement?