Skip to content

POWER

Return a number raised to a specified power.

POWER(number, power)

POW is a synonym for POWER.

Both arguments can be any number, including integer, decimal, and double precision values.

Return Type

If the first argument is an integer or a double precision value, the result is a double precision value.

If the first argument is a decimal value, the result is a decimal value. Decimal values are coerced to floating-point values for the calculation, then converted back to decimals in the result. The scale and precision of the result depend on the rules described in Calculations with DECIMAL Values.

Note: When the POWER function is used with decimal input values and the integral part of the result is greater than 38 minus the scale of the first argument, the function may return an overflow error.

Examples

For example:

premdb=# select power(10.12345,10) from sys.const;
      power        
--------------------
 11305386703.894196
(1 row)
premdb=# select capacity, pow(capacity,10) from team where avg_att>60;
 capacity |         pow          
----------+----------------------
   75635 | 6.12672112065688e+48
(1 row)
premdb=# select htid, atid, power(htid,atid) from team order by 1,2 asc limit 10;
 htid | atid |        power         
------+------+----------------------
   2 |   51 | 2.25179981368525e+15
   3 |   52 | 6.46108188922667e+24
   4 |   53 | 8.11296384146067e+31
   5 |   54 | 5.55111512312578e+37
   6 |   55 |   6.285195213566e+42
   7 |   56 | 2.11587613802425e+47
   8 |   57 | 2.99315535325369e+51
   9 |   58 | 2.21853123446226e+55
   10 |   59 |                1e+59
   11 |   60 | 3.04481639541418e+62
(10 rows)

See also Calculations with DECIMAL Values.