Function Reference

SQRT

Returns the square root of a number.

PostgreSQL 17.9
SQRT(num)
num
Non-negative number
numeric | double precision

Return value

A number of the same type (double precision or numeric); an error for a negative number

Examples

Square root of 4

PostgreSQL 17.9
SELECT SQRT(4);
sqrt
2

Root in double precision and numeric

PostgreSQL 17.9
SELECT SQRT(2) AS float_root,
	SQRT(2::numeric) AS numeric_root;
float_rootnumeric_root
1.41421356237309511.414213562373095

Details

The result type depends on the argument: SQRT(2) is double precision, while SQRT(2::numeric) is numeric. The short form is the |/ operator: |/ 16 = 4.

See also

Where to learn