Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change sign of a numeric variable in select statement? 1

Status
Not open for further replies.

CraigBest

Programmer
Aug 1, 2001
545
US
Hi,

I am trying to select a value from a table that I must use as a negative, but it is stored as a positive value. I would like to change the sign of the value in the select statement if that's possible so it can be used in a calculation as part of a stored procedure. I can't seem to find a function that will do this (sign simply returns 1 or -1 depending on the value of the field interrogated).

Anyone know of a way to do this?

Thanks

CraigHartz
 
why not this:
select -field from table;

or maybe:
select -field as field from table;
 
select your_field * -1
from your_table


In order to understand recursion, you must first understand recursion.
 
Yep, that did it - thanks. I figured it was something simple like that, especially when I couldn't find an example in the book :)

CraigHartz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top