Home » RDBMS Server » Server Administration » How do I achieve range of values using Decode
How do I achieve range of values using Decode [message #374339] Wed, 06 June 2001 11:13
Bruce Weinstein
Messages: 4
Registered: May 2001
Junior Member
Hope someone can help.

Here is my dilemma.

Based on a persons age, I want to return a specific value.

For example, if age < 20 then I want to return string '<20'. If age >=20 and < 25, return '>=20 & <25'.
If age >=25 and < 30, return '>=25 & <30'.
If age >=30 and < 35, return '>=30 & <35'.
And so on...going up by increments of 5 until 65.

I have following DECODE statement

decode(TRUNC(MONTHS_BETWEEN(SYSDATE,BIRTHDATE)/12),<45,'<45')

However, ORACLE does not seem to like it as I keep getting error. My guess is it does not like the <45.

Can someone help me out as I have been searching through the messages in this discussion list with no success.

Thanks in advance.
Previous Topic: Concatenation text issue
Next Topic: select largest tables with variables
Goto Forum:
  


Current Time: Fri Jul 05 11:53:33 CDT 2024