Skip to main content

POWER function

Returns the value of a number raised to the power of another number.

Syntax

POWER(base, exponent)

Arguments

  • base: A numeric expression representing the base value.

  • exponent: A numeric expression representing the exponent (power).

Returns

A DOUBLE representing the result of base raised to the power of exponent.

Special Cases

  • POWER(x, 0) returns 1 for any value of x (including negative and zero)

  • POWER(1, x) returns 1 for any value of x

  • POWER(0, x) returns 0 for positive x, inf for negative x

  • POWER(negative, non-integer) returns NaN

  • POWER(inf, positive) returns inf

  • POWER(inf, negative) returns 0

Examples

-- Example 1: Basic power calculations
> SELECT POWER(2, 3), POWER(-2, 3);
8, -8

-- Example 2: Negative exponents
> SELECT POWER(2, -3), POWER(-2, -3);
0.125, -0.125

-- Example 3: Fractional exponents
> SELECT POWER(4, 0.5), POWER(256, -0.25);
2, 0.25

-- Example 4: Special cases with 1 and 0
> SELECT POWER(1, -1234.567), POWER(-765.4321, 0), POWER(0, 5);
1, 1, 0

-- Example 5: Zero base with negative exponent (returns infinity)
> SELECT POWER(0, -0.5), POWER(0, -5);
inf, inf

-- Example 6: Negative base with non-integer exponent (returns NaN)
> SELECT POWER(-4, -0.5), POWER(-16, 0.5);
NaN, NaN

-- Example 7: Infinity as base
> SELECT POWER(CAST('inf' AS DOUBLE), -0.5), POWER(CAST('inf' AS DOUBLE), 5);
0, inf

-- Example 8: Infinity as exponent
> SELECT POWER(0.5, CAST('inf' AS DOUBLE)), POWER(0.5, CAST('-inf' AS DOUBLE));
0, inf

> SELECT POWER(45.6, CAST('inf' AS DOUBLE)), POWER(45.6, CAST('-inf' AS DOUBLE));
inf, 0

See Also