PostgreSQL 17.9
POWER(num, power)- num
- Basenumeric | double precision
- power
- Exponent, can be fractional or negativenumeric | double precision
Return value
A floating-point number (double precision), or numeric for numeric arguments; an error for a negative base with a fractional exponent
Examples
Square of a number
PostgreSQL 17.9
SELECT POWER(2, 2);Negative exponent
PostgreSQL 17.9
SELECT POWER(2, -1);Fractional exponent
PostgreSQL 17.9
SELECT POWER(9, 0.5);Details
For integer arguments the result is double precision. Instead of POWER you can use the ^ operator, but it is evaluated left to right: 2 ^ 3 ^ 2 = 64, not 512.