ABS function

Abs returns the absolute value of a number.


SQL> select abs(-1) from dual;

   ABS(-1)
----------
         1

SQL> select ABS(10) from dual;
   ABS(10)
----------
        10
SQL> select ABS(-10) from dual;
  ABS(-10)
----------
        10
SQL>

Using ABS function with column names.


create table TestTable(
      ID                 VARCHAR2(4 BYTE)         NOT NULL,
      MyNumber           Number(8,2)
    );

insert into TestTable (ID, MyNumber)values('1',12.12);
insert into TestTable (ID, MyNumber)values('1',-1.1);
insert into TestTable (ID, MyNumber)values('1',1.1);


SQL> select myNumber from testTable;

  MYNUMBER
----------
     12.12
      -1.1
       1.1

SQL>
SQL> select abs(myNumber) from testTable;

ABS(MYNUMBER)
-------------
        12.12
          1.1
          1.1

SQL>
Home »
Oracle »
Numeric Functions » 

Related: