Overview
TheABS()
function returns an absolute number, i.e., the positive value of a number. The data type of the returned value will depend on the data type of the value passed to the ABS()
function.
Syntax
The syntax for theABS()
function is as follows:
ABS()
function requires one argument:
x
: An expression that evaluates to a number.
The ABS() function will return the negation of the negative numbers.
Examples
Case #1: Absolute value of a negative number
The following example demonstrates how theABS()
function can be used to obtain the absolute value of a negative number:
Case #2: ABS() function with an expression
The following example demonstrates how theABS()
function can be used with an expression to obtain the absolute value of the result:
Case #3: Using the ABS() function with a table
The following example demonstrates how theABS()
function can be used with a table to obtain the absolute values of all numbers in a specific column:
- First, create a table named absTable containing an initialValue column with some positive and negative values:
- Next, use the following query to find the absolute value of all numbers:
- The above query will retrieve all values in the “initialValue” column and their absolute values in the “absoluteValue” column. The output will look something like this: