Raise a base to the given exponent (alias for POW).
POWER(base, exponent)
## Overview Returns the base raised to the given exponent. POWER is the SQL-standard name for exponentiation. It is fully interchangeable with POW and the two share every behavior, precision characteristic, and pitfall. Use POWER when targeting the SQL standard spelling or when the verbose form reads better in documentation; use POW for concise ad-hoc queries. Some engines optimize both paths identically. ## Behavior - Accepts any finite DOUBLE for both arguments. - Returns a DOUBLE. - Returns NULL if either argument is NULL. - POWER(x, 0) returns 1 for any x. - POWER(0, positive_exponent) returns 0. - POWER(0, negative_exponent) is undefined and typically returns NULL or positive infinity. - POWER of a negative base with a non-integer exponent returns NaN or NULL. ## Numeric precision - Uses the IEEE 754 double-precision pow routine. - For integer exponents, a sequence of multiplications is typically more accurate than POWER but also more verbose. - Fractional exponents that are not exactly representable (such as 1.0/3.0) introduce small rounding residues. - Overflows to infinity for very large results and underflows to 0 for very small results. ## Compatibility - POWER is the SQL standard spelling. POW is a synonym. - Matches typical mathematical library implementations.
| Name | Type | Description |
|---|---|---|
base | Specifies the base value. Accepts any finite DOUBLE. Negative bases with non-integer exponents are mathematically complex and typically return NaN or NULL. | |
exponent | Specifies the exponent. Accepts any finite DOUBLE, including negative and fractional values. Very large magnitudes may cause overflow or underflow. |
-- 3 raised to the 4th power
SELECT POWER(3, 4);
-- Result: 81.0
-- Fractional exponent
SELECT POWER(16, 0.25);
-- Result: 2.0
-- Negative exponent
SELECT POWER(10, -2);
-- Result: 0.01
-- Base 0 with a positive exponent is 0
SELECT POWER(0, 5);
-- Result: 0.0
-- Identity shared with POW
SELECT POWER(2, 10), POW(2, 10);
-- Result: 1024.0, 1024.0
-- Column use: compute geodesic-style squared distance component
SELECT segment_id, POWER(x2 - x1, 2) + POWER(y2 - y1, 2) AS squared_distance
FROM geometry.samples.segments;