Decode [message #19453] |
Tue, 19 March 2002 08:54 |
Satheesh
Messages: 6 Registered: September 2000
|
Junior Member |
|
|
Is it possible to use conditions like < (Less than) in Decode Function ?
e.g. decode(date_of_birth, < '01-JAn-2002', 'Young', 'Old');
|
|
|
Re: Decode [message #19454 is a reply to message #19453] |
Tue, 19 March 2002 09:50 |
Jon
Messages: 483 Registered: May 2001
|
Senior Member |
|
|
You want to use the case construct instead of decode, like this...
14:43:37 ==> drop table table1;
Table dropped.
14:43:51 ==> create table table1 (col1 number);
Table created.
14:44:03 ==> insert into table1 values(1);
1 row created.
14:44:10 ==> insert into table1 values(2);
1 row created.
14:44:19 ==> insert into table1 values(3);
1 row created.
14:44:24 ==> insert into table1 values(4);
1 row created.
14:46:44 ==> select case when col1 < 3 then 'small' else 'big' end from table1;
CASEW
-----
small
small
big
big
14:46:45 ==>
|
|
|
Re: Decode [message #19496 is a reply to message #19453] |
Thu, 21 March 2002 19:05 |
nash
Messages: 10 Registered: February 2002
|
Junior Member |
|
|
Yes, it is possible to use conditions like < (Less than) in Decode Function.
You can use the SIGN function available with decode.
EX : A table called balance has a field called AMT1,
which stores both Debit(+ive) and Credit(-ive) values.
Select decode(sign(amt1-0),amt1,0)) dr_amt,
decode(sign(0-amt1),amt1,0)) cr_amt
from balance.
decode(sign(0-amt1),amt1,0)) dr_amt :->
The above statement can be interpreted as
list all amt1 less than ( < ) zero.
---------------
Refer to Oracle documentation for more Info.
---------------
HTH
nash
|
|
|