Cloud

power

The power() function calculates the value of a number raised to the power of another number specified in the arguments.

Syntax

This example shows the syntax of the power() function:

POWER(a,b)

Where:

  • a: The base number.

  • b: The exponent to which the base number is raised.

Examples

Basic usage

In this case, the power() function calculates the result of raising one number to the power of another.

SELECT POWER(3, 4) AS "Example 1",
       POWER(7, 3) AS "Example 2";

The query returns:

 Example 1 | Example 2
-----------+-----------
        81 |       343

Use power() with negative values

In this case, the power() function is applied to negative numbers.

SELECT POWER(-4, -5), POWER(-1, -2), POWER(-6, -7);

The query returns:

 power | power | power
-------+-------+-------
 -1024 |     1 |     0

Use power() with floating-point numbers

In this example, use the power() function to calculate 2.5 raised to the power of 3.0.

SELECT POWER(2.5, 3.0) AS power_result;

The result, 15.625, is the value obtained by raising 2.5 to the third power.

 power_result
--------------
       15.625

Zero to the power of zero

This case shows that 0 expression raised to the power of 0 returns 1.

SELECT POWER(0, 0);

The query returns:

 power
-------
     1