asunpraise
MIS
The following query doesn't work. It seems decode function doesn't like < or > sign inside of it. But I need to compare clients' birth date to another date to get their age then and add them into a age group. Anybody knows how to do this?
select client_id,
decode(birth_date, MONTHS_BETWEEN(TO_DATE('01022003','DDMMYYYY'), TO_DATE(birth_date, 'DDMMYYYY')) < 13, 'Infant',
MONTHS_BETWEEN(TO_DATE('01022003','DDMMYYYY'), TO_DATE(birth_date, 'DDMMYYYY')) < 24, 'Toddler',
MONTHS_BETWEEN(TO_DATE('01022003','DDMMYYYY'), TO_DATE(birth_date, 'DDMMYYYY')) < 36, '2yr') Age
from clients;
select client_id,
decode(birth_date, MONTHS_BETWEEN(TO_DATE('01022003','DDMMYYYY'), TO_DATE(birth_date, 'DDMMYYYY')) < 13, 'Infant',
MONTHS_BETWEEN(TO_DATE('01022003','DDMMYYYY'), TO_DATE(birth_date, 'DDMMYYYY')) < 24, 'Toddler',
MONTHS_BETWEEN(TO_DATE('01022003','DDMMYYYY'), TO_DATE(birth_date, 'DDMMYYYY')) < 36, '2yr') Age
from clients;