w3resource

Oracle ABS() function

Description

The ABS() function is used to calculate the absolute value of an expression.

The function takes any numeric or nonnumeric data type (can be implicitly converted to a numeric data type) as an argument.
The function returns the same data type as the numeric data type of the argument.

Uses of Oracle ABS() Function
  • Calculate Absolute Values: Obtain the absolute value of both positive and negative numbers.

  • Data Normalization: Ensure that all numeric values are treated as non-negative for consistency in data analysis.

  • Mathematical Calculations: Assist in various mathematical computations where the absolute value is needed.

  • Financial Applications: Used in financial contexts to represent magnitude without regard to direction, such as profit and loss calculations.

  • Data Cleaning: Convert negative values to positive to maintain consistency in datasets.

Syntax:

 ABS(N); 

Parameters:

Name Description
N A number whose absolute value is to be retrieved.

Pictorial Presentation of ABS() function

Pictorial Presentation of Oracle ABS() function

Example: ABS() function using positive value

The example below shows that, the oracle statement will return the absolute value of a positive number specified in the argument.

SELECT ABS(5) FROM dual;

Here is the result.

    ABS(5)
----------
         5

Example: ABS() function using negative value

The example below shows that, the oracle statement will return the absolute value of a negative number defined in the argument.

SELECT ABS(-5) FROM dual;

Here is the output.

    ABS(5)
----------
         5

Previous: Oracle Numeric Functions Introduction
Next: ACOS



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/oracle/oracle-numeric-functions/oracle-abs-function.php