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.
Author |
Topic |
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2006-11-30 : 05:20:56
|
I have a field in a table where the values can be positive and negative but I want to get only the absolute valueEg: The field value can be -3 then the value to be returned is 3 /-3/ = 3 or if its 3 then it should return 3 itself |
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2006-11-30 : 05:24:43
|
mmmmm.... the ABS function - returns absolute valueSELECT ABS(-13), ABS(3)Duane. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-30 : 05:39:44
|
Damn. Why is the easy one already taken? select case when sign(yourcolumn) < 0 then -1 * yourcolumn else yourcolumn endfrom yourtablePeter LarssonHelsingborg, Sweden |
 |
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2006-11-30 : 05:40:08
|
Thanks totaly forgot... |
 |
|
|
|
|