ABS
Returns the absolute value of the numeric argument.
See also:
[SELECT
]
Syntax
SELECT ABS(numeric_expression) FROM <multipartIdentifier>;
abs(X)
returnsNULL
ifX
isNULL
.abs(X)
returns0.0
ifX
is a string or blob that cannot be converted to a numeric value. IfX
is the integer -9223372036854775808 thenabs(X)
throws an integer overflow error since there is no equivalent positive 64-bit two complement value.
Arguments
numeric_expression
An expression of the exact numeric or approximate numeric data type category.
Return Value(s)
Returns a positive numeric value.
Examples
Return the absolute value of a number
SELECT name, abs(strftime('%s', creationTimestamp)-strftime('%s','now')) as abs_value
FROM google.compute.instances
WHERE project = 'stackql-demo'
AND zone = 'australia-southeast1-a';
For more information, see https://www.sqlite.org/lang_mathfunc.html