Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

convert positive to negative in SQL

How can I convert below number to positive number?

-2650.000000
0
VBdotnet2005
Asked:
VBdotnet2005
  • 2
4 Solutions
 
hnasrCommented:
ABS (-2650.000000)
0
 
hnasrCommented:
The question head mentioned to negative, but its text mentioned positive.

Try: for a number i,
SELECT -(i);

Specific example: -(-2650.000000)
0
 
Neil RussellTechnical Development LeadCommented:
Or of course multiply by -1 IF you know its always negative.  But if you only ever want a positive and dont know if it will be positive or negative to start with then use hnasr's example of ABS(number).
0
 
awking00Commented:
I'm not sure of what it is you're trying to do, but these commands (some already suggested) will generate the following results:
Multiply by -1 ==> will convert negative to positive and positive to negative
Use ABS() function ==> will always return positive (i.e. converts negative to positive and leaves positive as positive)
Multiply ABS() function by - 1 ==> will always return negative
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now