SQLite abs() Function
The SQLite abs() function returns the absolute value of the value specified by the parameter.
Syntax
Here is the syntax of the SQLite abs() function:
abs(numeric_value)
Parameters
numeric_value-
Required. A number, it can be positive, negative, or zero, it can be an integer or a decimal.
Return value
The SQLite abs() function returns the absolute value of numeric_value.
The abs() function will return NULL if the parameter numeric_value is NULL.
If you provide a non numeric argument, the SQLite abs() function will return 0.0.
Examples
Here are a few examples of the abs() function.
SELECT
abs(0),
abs(7),
abs(-7),
abs(1.2),
abs(-1.2);
abs(0) = 0
abs(7) = 7
abs(-7) = 7
abs(1.2) = 1.2
abs(-1.2) = 1.2The SQLite abs() function will return 0.0 if you use a parameter that is not a numeric type.
SELECT abs('abc');
abs('abc') = 0.0