Monday, February 14, 2011

SIGN


The SIGN function evaluates a column, value or expression and returns -1 if it is negative, 0 if it is zero and 1 if it is positive. I tried to catch it out but failed: 

TEST9 > sqlplus /

SQL*Plus: Release 9.2.0.7.0 - Production on Mon Feb 14 17:28:45 2011

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
With the Partitioning option
JServer Release 9.2.0.7.0 - Production

SQL> select sign(-5) from dual;

  SIGN(-5)
----------
        -1

SQL> select sign(-0) from dual;

  SIGN(-0)
----------
         0

SQL> select sign(0) from dual;

   SIGN(0)
----------
         0

SQL> select sign(+0) from dual;

  SIGN(+0)
----------
         0

SQL> select sign(6.3) from dual;

 SIGN(6.3)
----------
         1

SQL> select sign(-2.5 * -1.7) from dual;

SIGN(-2.5*-1.7)
---------------
              1

SQL> select sign(-2 / -3) from dual;

SIGN(-2/-3)
-----------
          1

SQL>

No comments:

Post a Comment