ABS¶
The ABS function is used to calculate the absolute value of a number. It takes a single numeric argument and returns the absolute value of that number. The argument can be an integer, decimal, or float value.
Syntax¶
value: A numeric expression for which the absolute value is to be calculated.
Examples¶
Let's consider a table named SingleItem with the following schema:
Insert a row into the SingleItem table:
Example 1: Using ABS with integer values¶
Result:
Example 2: Using ABS with float values¶
Result:
Example 3: Using ABS with table columns¶
Result:
Example 4: Using ABS with NULL values¶
Result:
Errors¶
The ABS function requires a numeric value as its argument. Using non-numeric values or more than one argument will result in an error.
Example 5: Using ABS with non-numeric values¶
Error: Function requires a numeric value.
Example 6: Using ABS with multiple arguments¶
Error: Function expects 1 argument, but 2 were provided.