SQRT
Returns the square root of a number.
PostgreSQL 17.9
SQRT(num)- num
- Non-negative numbernumeric | 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);Root in double precision and numeric
PostgreSQL 17.9
SELECT SQRT(2) AS float_root,
SQRT(2::numeric) AS numeric_root;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.