Skip to main content
Scalar function
Aliases: sign Returns NULL for a NULL numeric or interval input. Both positive and negative numeric zero produce 0.0; numeric NaN remains NaN.

Syntax

Numeric or interval

Arguments

Numeric

Interval

Returns

  • Type: DOUBLE
  • Possible values: -1.0 for negative values, 0.0 for zero and 1.0 for positive values; numeric NaN remains NaN.
  • NULL behavior: Returns NULL for a NULL numeric or interval input. Both positive and negative numeric zero produce 0.0; numeric NaN remains NaN.

Properties

Usage notes

  • Numeric input is cast to DOUBLE before taking its sign.
  • For year-month intervals the sign follows the month count. For day-time intervals it follows days plus milliseconds. For month-day-nanosecond intervals, a nonzero month component determines the sign; otherwise days plus nanoseconds determine it.
  • INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

Examples

Value and NULL input

Interval sign and NULL

Last modified on October 15, 2026