sign function

Returns -1.0, 0.0, or 1.0 as expr is negative, 0, or positive.

Syntax

sign(expr)

Arguments

  • expr: An expression that evaluates to a numeric or interval.

Interval is supported since: Databricks Runtime 10.1

Returns

A DOUBLE.

This function is a synonym for signum function.

Examples

> SELECT sign(40);
 1.0

> SELECT sign(INTERVAL'-1' DAY)
 -1.0