Solved

convert positive to negative in SQL

Posted on 2014-12-19
4
128 Views
Last Modified: 2014-12-21
How can I convert below number to positive number?

-2650.000000
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 250 total points
ID: 40510266
ABS (-2650.000000)
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 250 total points
ID: 40510282
The question head mentioned to negative, but its text mentioned positive.

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

Specific example: -(-2650.000000)
0
 
LVL 37

Assisted Solution

by:Neil Russell
Neil Russell earned 125 total points
ID: 40510538
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
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 125 total points
ID: 40510935
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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

728 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