Postgresql Sqrt Function

PostgreSQL: sqrt Function

In this PostgreSQL post explains how to use the PostgreSQL sqrt function with syntax and examples.

Description

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

Syntax

The syntax for the sqrt function in PostgreSQL is:

sqrt( number )

Parameters or Arguments

number

The positive number to take the square root of.

Note

  • The sqrt function will return an error, if the number is a negative value.

Applies To

The sqrt function can be used in the following versions of PostgreSQL:

  • PostgreSQL 9.4, PostgreSQL 9.3, PostgreSQL 9.2, PostgreSQL 9.1, PostgreSQL 9.0, PostgreSQL 8.4

Example

Let's look at some PostgreSQL sqrt function examples and explore how to use the sqrt function in PostgreSQL.

For example:

postgres=# SELECT sqrt(25);
 sqrt
------

    5
(1 row)

postgres=# SELECT sqrt(26);
       sqrt
------------------

 5.09901951359278
(1 row)

postgres=# SELECT sqrt(0);
 sqrt
------

    0
(1 row)