PostgreSQL 18 reference · Math Functions
PostgreSQL POWER() Function
Raise a number to a power, so power(2, 10) is 1024. pow() is another name for the same function.
PostgreSQL 18
Syntax
power(a, b) | pow(a, b)
Parameters
| Parameter | Description |
|---|---|
a |
The base. |
b |
The exponent. |
Return value
double precision or numeric.
Examples
SELECT power(2, 10) AS a, power(9, 0.5) AS b;
Output
a | b ------+-------------------- 1024 | 3.0000000000000000 (1 row)
Run this on your computer — see “Get Started” for setup.
SELECT round(1000 * power(1.05, 10), 2) AS after_10_years;
Output
after_10_years
----------------
1628.89
(1 row)Run this on your computer — see “Get Started” for setup.
In other languages
POWER()· SQLite
Related
SQRT()· Return the square root of a number, so sqrt(16) is 4. Negative input raises an error; cbrt() gives the cube root.LN()· Return the natural logarithm (base e) of a number. exp() is the inverse.- SQL Aggregate Functions · tutorial