?
Solved

convert positive to negative in SQL

Posted on 2014-12-19
4
Medium Priority
?
140 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 1000 total points
ID: 40510266
ABS (-2650.000000)
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 1000 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 500 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 500 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

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!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

765 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