Oracle SQL - Function ABS function

Introduction

ABS function returns the absolute value of a number or value.

In the following code, ABS returns the absolute value of VALUE.

Demo

SQL>
SQL> drop table my_table;

Table dropped.--  www  .  j a va2 s .c  o  m

SQL> CREATE TABLE my_table (
  2      LINENO NUMBER(2) not null,
  3      VALUE NUMBER(6,2) not null
  4  );
SQL>
SQL> insert into my_table values(1,1.2);
SQL> insert into my_table values(2,123.34);
SQL> insert into my_table values(3,-12.2);
SQL> insert into my_table values(4,100);
SQL> insert into my_table values(5,48);
SQL> insert into my_table values(6,-90);
SQL> insert into my_table values(7,0.19);
SQL>
SQL> SELECT lineno, value, ABS(value), SIGN(value), MOD(lineno,3)
  2  FROM my_table
  3  ORDER BY lineno;

   LINENO |     VALUE | ABS(VALUE) | SIGN(VALUE) | MOD(LINENO,3)
--------- | --------- | ---------- | ----------- | -------------
 00001.00 |  00001.20 |   00001.20 |    00001.00 |      00001.00
 00002.00 |  00123.34 |   00123.34 |    00001.00 |      00002.00
 00003.00 | -00012.20 |   00012.20 |   -00001.00 |      00000.00
 00004.00 |  00100.00 |   00100.00 |    00001.00 |      00001.00
 00005.00 |  00048.00 |   00048.00 |    00001.00 |      00002.00
 00006.00 | -00090.00 |   00090.00 |   -00001.00 |      00000.00
 00007.00 |  00000.19 |   00000.19 |    00001.00 |      00001.00

7 rows selected.

SQL>