Charles,
I am trying to get a headcount but when I use the logic listed below it only returns 5.
CASE
WHEN (SYSDATE - BIRTHDATE) BETWEEN 0 AND 29 THEN 1
WHEN (SYSDATE - BIRTHDATE) BETWEEN 30 AND 39 THEN 2
WHEN (SYSDATE - BIRTHDATE) BETWEEN 40 AND 49 THEN 3
WHEN (SYSDATE - BIRTHDATE) BETWEEN 50 AND 59 THEN 4
else 5
end
I also tried the code listed below and still receiving only 5.
CASE
when trunc((SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE")) < 5 then 1
when trunc((SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE")) < 10 then 2
when trunc((SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE")) < 15 then 3
when trunc((SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE")) < 20 then 4
Else 5
end
trunc(SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE") returns a value in days. To get years divide by 365.
Try this:
CASE
when TRUNC((SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE") / 365) < 5 then 1
when TRUNC((SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE") / 365) < 10 then 2
when TRUNC((SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE") / 365) < 15 then 3
when TRUNC((SYSDATE - "PS_PERSONAL_DATA"."BIRTHDATE") / 365) < 20 then 4
Else 5
end
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.