Home » SQL & PL/SQL » SQL & PL/SQL » decode function condition
decode function condition [message #20445] Fri, 24 May 2002 09:55 Go to next message
vimal
Messages: 46
Registered: February 2000
Member
i want to run a sql statement using decode function suppose i have a column callled lv_bal from tbl

is it possible or not . if not then whats the alternate solution of it

select decode(lv_bal, <1 ,0,lv_bal) from tbl

pls inform me soon
Re: decode function condition [message #20446 is a reply to message #20445] Fri, 24 May 2002 10:09 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
sql>select c, decode(sign(c-1), -1, 0, c) c_new
  2    from t;
 
        C     C_NEW
--------- ---------
    10.24     10.24
      1.5       1.5
       .2         0
      .01         0
        0         0
   175.99    175.99
        1         1
Re: decode function condition [message #20452 is a reply to message #20445] Sat, 25 May 2002 08:14 Go to previous messageGo to next message
N. Rammohan
Messages: 5
Registered: May 2002
Junior Member
select decode(lv_bal,greaest(0,least(1,2)),least(1,2),lv_bal) from tbl;

pl try and revert back
Re: decode function condition [message #20454 is a reply to message #20452] Sat, 25 May 2002 08:36 Go to previous messageGo to next message
vimal
Messages: 1
Registered: May 2002
Junior Member
no its work some what like this

select lv_bal , decode(lv_bal,least(lv_bal,0),0,lv_bal) kk from tt_lvbalchk

but thanx for the reply i highly appreciate you coz u give me tha way to think in that way RAM
Re: decode function condition [message #20496 is a reply to message #20445] Wed, 29 May 2002 22:41 Go to previous message
shyampaliyath
Messages: 22
Registered: May 2002
Junior Member
hai vimal,
u could go like this
select decode(greatest(lv_bal,0), lv_bal ,lv_bal,0) from tbl

or

select (case when lv_bal>0 then lv_bal else 0 end) from
tbl
Previous Topic: Finding date processing a tad difficult
Next Topic: how to retriev the data
Goto Forum:
  


Current Time: Tue May 21 19:31:47 CDT 2024