Is there a way to CAST as an INTEGER within a CASE Statement ?
CASE
WHEN SV.END_DATE IS NOT NULL THEN SV.END_DATE - SV.START_DATE
ELSE 0
END AS DAYDIFF
Yes, you could cast the value to a numeric data type with no fractional part:
CASE
WHEN SV.END_DATE IS NOT NULL THEN
CAST(SV.END_DATE - SV.START_DATE AS NUMBER(38))
ELSE 0
END AS DAYDIFF
or you could truncate the result, which also strips the fractional part of the value:
CASE
WHEN SV.END_DATE IS NOT NULL THEN
TRUNC(SV.END_DATE - SV.START_DATE)
ELSE 0
END AS DAYDIFF
end_dateandstart_date? Get the number of whole days between them? or something else? Sample data and expected results might make things clearer too.