Skip to main content

SQRT

The SQRT function is used to calculate the square root of a number. It takes one argument, which must be of the FLOAT type. The result will also be of the FLOAT type.

Syntax

SQRT(number)

Examples

  1. Using the SQRT function:
SELECT SQRT(2.0) as sqrt_1;
-- Result: 1.4142135623730951
  1. Using the SQRT function with a decimal:
SELECT SQRT(0.07) as sqrt_2;
-- Result: 0.2645751311064591
  1. Using the SQRT function with an integer:
SELECT SQRT(32) as sqrt_with_int;
-- Result: 5.656854249492381
  1. Using the SQRT function with zero:
SELECT SQRT(0) as sqrt_with_zero;
-- Result: 0.0
  1. Using the SQRT function with NULL:
SELECT SQRT(NULL) AS sqrt;
-- Result: NULL

Error Cases

  1. The SQRT function requires the argument to be of FLOAT type:
SELECT SQRT('string') AS sqrt;
-- Error: SqrtOnNonNumeric("string")