In this PostgreSQL post explains how to use the PostgreSQL power function with syntax and examples.
The PostgreSQL power function returns m raised to the nth power.
The syntax for the power function in PostgreSQL is:
power( m, n )
The base to use in the power function.
The exponent to use in the power function.
The power function can be used in the following versions of PostgreSQL:
Let's look at some PostgreSQL power function examples and explore how to use the power function in PostgreSQL.
For example:
postgres=# SELECT power(6, 2);
power
-------
36
(1 row)
postgres=# SELECT power(6, -2);
power
--------------------
0.0277777777777778
(1 row)
postgres=# SELECT power(5.4, 3);
power
----------------------
157.4640000000000000
(1 row)
postgres=# SELECT power(0, 3);
power
-------
0
(1 row)
postgres=# SELECT power(3, 0);
power
-------
1
(1 row)