Skip to main content

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 a string or BLOB that cannot be losslessly converted into a number, then the function will return NULL.

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