Solved

MS SQL Convert Positive Value in Negative

Posted on 2006-07-15
4
692 Views
Last Modified: 2008-02-01
Sir, we are using abs function for converting negative value in positive. I want to convert positive value in Negative. please help if is there any function for converting positive value in negative.

Rgds.
Mehram
0
Comment
Question by:Mehram
  • 2
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17114855
Use something like this

If  @urintValue > 0
  SEt urIntValue =  0 - @urInteValue


There is no ssystem function for this purpose , you can write ur own function to do this with the above logic
0
 

Author Comment

by:Mehram
ID: 17114869
Sir I am using following statement and I want to convert credit column in negative.

select file_job, d='0'+expensecode, headsub, credit, expensedate  
from cargoinvoicedetail where expensecode='0437' and credit > '0' order by 5

In this can i use if, if yes please help how?
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 17114877
select file_job, d='0'+expensecode, headsub, -1*credit, expensedate  
from cargoinvoicedetail where expensecode='0437' and credit > '0' order by 5

0
 

Author Comment

by:Mehram
ID: 17114881
Tks it is excellent
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: I have seen many questions on EE and elsewhere, asking about how to find either gaps in lists of numbers (id field, usually) ranges of values or dates overlapping date ranges combined date ranges I thought it would be a good …
In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now