Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL to change negative number to positive number

user16854Feb 9 2010 — edited Feb 9 2010
Apologies for the no doubt high "thick-as-a-plank" nature of my query.

Is there any way to convert a negative number to a positive number using SQL. I have a report which joins 2 tables, and I want to join the tables on a 'Quantity' field. Trouble is that the QTYs in 1 table are negative, and the QTYs in the other are positives. I know that that in itself is a stupid thing to do, but anyway.

I just wondered if there is a simple way to get the positive number versions of the numbers:
GET sampledata
WITH sampledata AS
     (SELECT -345 var_num
        FROM DUAL
      UNION ALL
      SELECT -423423
        FROM DUAL
      UNION ALL
      SELECT -323.5
        FROM DUAL)
SELECT *
  FROM sampledata;
Any advice much appreciated.

Thank you

Edited by: jimr on Feb 9, 2010 12:38 PM
Changed subject
This post has been answered by 21205 on Feb 9 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 9 2010
Added on Feb 9 2010
4 comments
12,983 views