Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 decode

Author  Topic 

ayyoob1234
Starting Member

3 Posts

Posted - 2013-06-11 : 13:22:32
hi

i am trying to add a math function inside a decode. is it possible.

for eg.

select account_id, decode(transaction_amount, < 0, 'Debit', > 0, 'Credit'
from table


plzz help

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-06-11 : 13:27:00
hmm so you're using Oracle .. by the way this forum is specifically for SQL server...

Now to yours question .. you may need to use Case Statment.
select account_id
CASE WHEN transaction_amount < 0 THEN 'Debit' ELSE 'Credit' END
from table

Cheers
MIK
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-06-12 : 00:22:34
You can use SIGN() Function to find whether -ve or +ve and then apply DECODE functionality...........
Check the below modified code
quote:
Originally posted by ayyoob1234

hi

i am trying to add a math function inside a decode. is it possible.

for eg.
select account_id, decode(SIGN(transaction_amount), -1, 'Debit', 1, 'Credit')
from table


plzz help



--
Chandu
Go to Top of Page
   

- Advertisement -