Purpose
This function returns the power of a specified number.
Syntax
POWER (x, y)
Parameters
Parameter |
Description |
|---|---|
| x | The base, which is an expression of the NUMBER, FLOAT, BINARY_FLOAT, or BINARY_DOUBLE data type. |
| y | The exponent, which is an expression of the NUMBER, FLOAT, BINARY_FLOAT, or BINARY_DOUBLE data type. If x is a negative number, y must be an integer. |
Return type
If the parameter is of the BINARY_FLOAT or BINARY_DOUBLE data type, the return type is BINARY_DOUBLE. Otherwise, the return type is NUMBER.
Examples
Return the square of 3, the cube of -3, and the -2 power of 4.
obclient> SELECT POWER(3,2),POWER(-3,3),POWER(4,-2) FROM DUAL;
+------------+-------------+-------------+
| POWER(3,2) | POWER(-3,3) | POWER(4,-2) |
+------------+-------------+-------------+
| 9 | -27 | .0625 |
+------------+-------------+-------------+
1 row in set
