Postgresql Power Function

PostgreSQL: power Function

In this PostgreSQL post explains how to use the PostgreSQL power function with syntax and examples.

Description

The PostgreSQL power function returns m raised to the nth power.

Syntax

The syntax for the power function in PostgreSQL is:

power( m, n )

Parameters or Arguments

m

The base to use in the power function.

n

The exponent to use in the power function.

Applies To

The power function can be used in the following versions of PostgreSQL:

  • PostgreSQL 9.4, PostgreSQL 9.3, PostgreSQL 9.2, PostgreSQL 9.1, PostgreSQL 9.0, PostgreSQL 8.4

Example

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)