Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

decode function with more conditions and same outputs

Status
Not open for further replies.

chochoo

Programmer
Joined
Aug 24, 2003
Messages
33
Location
PK
hi all
i m using oracle8i and my query is that
select dat,decode(v_type,'ct',sum(account)debit,
decode(v_type,'cr',sum(account) credit)
from voucher
group by dat;
this query works fine but if i increase the conditions, i-e
decode(v_type,'ct','ds','gs','ps',sum(account) debit,
this makes some wrong results , my requirement is that if i've these four condtions then all values will be submittedto debit column and rest to credit.
 
decode(v_type
, 'ct', sum(account)debit
, 'ds', sum(account) debit
,'gs', sum(account)debit
, 'ps', sum(account)debit
, sum(account) credit)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top