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
expressionis negative, the result isNaN(Not a Number).If
expressionisinf(positive infinity), the result isinf.
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 toPOWER(x, 0.5).
See Also
POWER function - Raise to a power
ABS function - Absolute value