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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 change -ve to +ve

Author  Topic 

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2008-09-05 : 12:26:06
Hi,

I have 2 columns having the sample data like this.

COLA COLB
-1 2
-1 -4
-2 4
1 -3

When i am multiplying the two columns i will get if two values having -ve sign then i will get +ve sign.

So i need, when i multiply with -1 with -3 or 4 i have to get the +ve sign.

In maths if we have -1, if we want to be +ve we will use MOD, like that do we have any other thing in TSQL

can i get query for this

regards

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-09-05 : 12:36:17
Are you saying that you want to display -1 * -2 as +2
and 1 * 2 as + 2 ?
Jim
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-09-05 : 14:58:20
I dont understand your question completely, but you can use

SELECT ABS(-1)

for MOD
Go to Top of Page

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2008-09-05 : 15:20:36
Thanks rohit

quote:
Originally posted by rohitkumar

I dont understand your question completely, but you can use

SELECT ABS(-1)

for MOD

Go to Top of Page

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2008-09-05 : 15:21:31
Thanks rohit,ABS(-1) is working
Go to Top of Page
   

- Advertisement -