SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 decode
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ayyoob1234
Starting Member

3 Posts

Posted - 06/11/2013 :  13:22:32  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Pakistan
1052 Posts

Posted - 06/11/2013 :  13:27:00  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2206 Posts

Posted - 06/12/2013 :  00:22:34  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000