PostgreSQL sqrt() Function

The PostgreSQL sqrt() function returns the square root of a given number.

sqrt() Syntax

This is the syntax of the PostgreSQL sqrt() function:

sqrt(numeric_value) -> numeric_type

Parameters

numeric_value

Required. a number.

Return value

The PostgreSQL sqrt(numeric_value) function returns the square root of numeric_value.

The sqrt() function will return NULL if the argument is NULL.

PostgreSQL will give an error if you supply a parameter that is not a numeric type.

sqrt() Examples

Here are a few examples of the sqrt() function:

SELECT
    sqrt(4) AS "sqrt(4)",
    sqrt(9) AS "sqrt(9)",
    sqrt(2) AS "sqrt(2)";
 sqrt(4) | sqrt(9) |      sqrt(2)
---------+---------+--------------------
       2 |       3 | 1.4142135623730951