Skip to main content

SQRT function

Returns the square root of a numeric expression.

Syntax

SQRT(expression)

Arguments

  • expression: A numeric expression.

Returns

A DOUBLE representing the square root of the input value.

Special Values

  • If expression is negative, the result is NaN (Not a Number).

  • If expression is inf (positive infinity), the result is inf.

Examples

-- Example 1: Square root of perfect squares
> SELECT SQRT(25);
5

> SELECT SQRT(0.25);
0.5

-- Example 2: Square root of zero and one
> SELECT SQRT(0);
0

> SELECT SQRT(1);
1

-- Example 3: Square root of negative numbers returns NaN
> SELECT SQRT(-1);
NaN

> SELECT SQRT(-0.25);
NaN

-- Example 4: Square root of infinity
> SELECT SQRT(CAST('inf' AS DOUBLE));
inf

Notes

  • SQRT(x) is equivalent to POWER(x, 0.5).

See Also