Home » SQL & PL/SQL » SQL & PL/SQL » relational operator in decode
relational operator in decode [message #303078] |
Wed, 27 February 2008 22:01  |
sirfkashif
Messages: 70 Registered: September 2007 Location: Rawalpindi
|
Member |
|
|
Dear all,
I would like to know weather we can use relational operator in decode function or not because i am not able to find any help regarding that
and i would not like to use case statement because we are using oracle 8i and case does not seem to work on that
expected query
decode(sal, sal<0, 'Low Salary', sal<0 , 'High Salary',sal)
|
|
|
|
|
Re: relational operator in decode [message #303101 is a reply to message #303078] |
Thu, 28 February 2008 00:11   |
hb_venkatesh
Messages: 9 Registered: October 2007 Location: india
|
Junior Member |

|
|
we could not use relation opertor in decode function because it
could not suppoet <,>,>=,<=
>decode(sal, sal<0, 'Low Salary', sal<0 , 'High Salary',sal)
you will try like
decode(sal, sign(sal),-1,'Low Salary',1, 'High Salary',0)
Before that youjust read about SIGN function
venki
|
|
|
|
Re: relational operator in decode [message #303112 is a reply to message #303101] |
Thu, 28 February 2008 00:43   |
hb_venkatesh
Messages: 9 Registered: October 2007 Location: india
|
Junior Member |

|
|
Hello Michal,
>Is this not what flyboy said and pointed to?
select decode( sign(100),-1,'negative',1,'positive',0) from dual union all
select decode(sign(-100), -1,'negative',1,'positive',0) from dual
I'made a small mistake from my previous query
>decode(sal, sal<0, 'Low Salary', sal>0 , 'High Salary',sal)
>you will try like
>decode(sal, sign(sal),-1,'Low Salary',1, 'High Salary',0)
remove it this and
decode(sign(sal),-1,'Low Salary',1, 'High Salary',0)
If you use sign() function for eg:
Query Result
sign(-100) => -1 (if less than 0, the result is -1)
sign(0) => 0 (if value is 0, the result is 0)
sign(100) => 1 (if greater than 0, the result is 1)
venki
|
|
|
|
Goto Forum:
Current Time: Thu Feb 06 23:11:27 CST 2025
|