Home » SQL & PL/SQL » SQL & PL/SQL » AND condition in DECODE
AND condition in DECODE [message #20243] Wed, 08 May 2002 12:02 Go to next message
sri
Messages: 154
Registered: February 2000
Senior Member
How can I use and condition in decode.
I have the sitaution like this -

if (updt_typ = a) and (flmnt_id = y) then
1 else null
Re: AND condition in DECODE [message #20245 is a reply to message #20243] Wed, 08 May 2002 12:59 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
I would lean toward method1, but here are a couple of ways to do it:

sql>select updt_typ, flmnt_id,
  2         decode(updt_typ, 'a', decode(flmnt_id, 'y', 1, null), null) method1,
  3         decode(updt_typ || flmnt_id, 'ay', 1, null) method2
  4    from t;
 
U F   METHOD1   METHOD2
- - --------- ---------
a y         1         1
a n
b y
b n
x x
Re: AND condition in DECODE [message #20280 is a reply to message #20243] Fri, 10 May 2002 11:04 Go to previous messageGo to next message
bechir
Messages: 23
Registered: November 2001
Junior Member
make sure that you trim the fields(updt_typ and flmnt_id)if their data type is CHAR.
Re: AND condition in DECODE [message #20319 is a reply to message #20243] Mon, 13 May 2002 10:44 Go to previous message
sri
Messages: 154
Registered: February 2000
Senior Member
Thanks!
Previous Topic: Installing Sequence
Next Topic: Library function
Goto Forum:
  


Current Time: Mon May 20 15:28:07 CDT 2024