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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.