Home » SQL & PL/SQL » SQL & PL/SQL » negate a value
negate a value [message #8916] Fri, 03 October 2003 05:32 Go to next message
neeraj
Messages: 16
Registered: October 2001
Junior Member
is there any function to negate a value
e.g if a= 3
then
output should be
a = -3
else
if a =-3
then output should be
a=3
Re: negate a value [message #8918 is a reply to message #8916] Fri, 03 October 2003 06:24 Go to previous message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Sure, just put a negative sign in front of the value whose negative value you want:
SQL> CREATE TABLE t (n NUMBER);
  
Table created.
  
SQL> INSERT INTO t VALUES (-2);
SQL> INSERT INTO t VALUES (0);
SQL> INSERT INTO t VALUES (5);
SQL> COMMIT;
  
Commit complete.
  
SQL> SELECT n
  2  ,      -n negative
  3  FROM   t
  4  /
  
         N   NEGATIVE
---------- ----------
        -2          2
         0          0
         5         -5
  
SQL> 
HTH,

A.
Previous Topic: Urgent ! 2 lakh records in database
Next Topic: How to populate County
Goto Forum:
  


Current Time: Thu Apr 25 12:29:14 CDT 2024