SIGN
Returns -1 if the input value is negative, 0 if the input value is 0, and 1 is the input value is positive.
See also:
[SELECT
]
Syntax
SELECT SIGN(numeric_expression) FROM <multipartIdentifier>;
Arguments
numeric_expression
An expression of the exact numeric or approximate numeric data type category.
If numeric_expression is
NULL
or is astring
or BLOB that cannot be losslessly converted into a number, then the function will returnNULL
.
Return Value(s)
Returns -1
, 0
or 1
.
Examples
Determine the sign of a number
SELECT name, sign(strftime('%s', creationTimestamp)-strftime('%s','now')) as sign
FROM google.compute.instances
WHERE project = 'stackql-demo'
AND zone = 'australia-southeast1-a';
For more information, see https://www.sqlite.org/lang_corefunc.html#sign