All Products
Search
Document Center

MaxCompute:POW

Last Updated:Mar 26, 2026

Returns x raised to the power of y (x^y).

Syntax

double|decimal pow(<x>, <y>)

Parameters

Parameter Required Type Description
x Yes DOUBLE or DECIMAL The base. STRING and BIGINT inputs are implicitly converted to DOUBLE before calculation.
y Yes DOUBLE or DECIMAL The exponent. STRING and BIGINT inputs are implicitly converted to DOUBLE before calculation.

Return value

Input types Return type
x or y is DOUBLE DOUBLE
x or y is DECIMAL DECIMAL
x or y is STRING or BIGINT DOUBLE
x or y is null null

Examples

Static values

-- Integer exponent: returns 65536.0
SELECT pow(2, 16);

-- Null input: returns null
SELECT pow(2, null);

Table data

This example uses the mf_math_fun_t sample table. Create the table and insert sample data:

CREATE TABLE IF NOT EXISTS mf_math_fun_t (
    int_data     INT,
    bigint_data  BIGINT,
    double_data  DOUBLE,
    decimal_data DECIMAL,
    float_data   FLOAT,
    string_data  STRING
);

INSERT INTO mf_math_fun_t VALUES
(null, -10,   0.525,  0.525BD,  CAST(0.525 AS FLOAT),  '10'),
(-20,  null,  -0.1,   -0.1BD,   CAST(-0.1 AS FLOAT),   '-10'),
(0,    -1,    null,   20.45BD,  CAST(-1 AS FLOAT),     '30'),
(-40,  4,     0.89,   null,     CAST(0.89 AS FLOAT),   '-30'),
(5,    -50,   -1,     -1BD,     null,                  '50'),
(-60,  6,     1.5,    1.5BD,    CAST(1.5 AS FLOAT),    '-50'),
(-1,   -70,   -7.5,   -7.5BD,   CAST(-7.5 AS FLOAT),  null),
(-80,  1,     -10.2,  -10.2BD,  CAST(-10.2 AS FLOAT),  '-1'),
(9,    -90,   2.58,   2.58BD,   CAST(2.58 AS FLOAT),   '0'),
(-100, 10,    -5.8,   -5.8BD,   CAST(-5.8 AS FLOAT),   '-90');

Query all rows from the table to verify the data:

SELECT * FROM mf_math_fun_t;

Result:

+------------+-------------+-------------+--------------+------------+-------------+
| int_data   | bigint_data | double_data | decimal_data | float_data | string_data |
+------------+-------------+-------------+--------------+------------+-------------+
| NULL       | -10         | 0.525       | 0.525        | 0.525      | 10          |
| -20        | NULL        | -0.1        | -0.1         | -0.1       | -10         |
| 0          | -1          | NULL        | 20.45        | -1.0       | 30          |
| -40        | 4           | 0.89        | NULL         | 0.89       | -30         |
| 5          | -50         | -1.0        | -1           | NULL       | 50          |
| -60        | 6           | 1.5         | 1.5          | 1.5        | -50         |
| -1         | -70         | -7.5        | -7.5         | -7.5       | NULL        |
| -80        | 1           | -10.2       | -10.2        | -10.2      | -1          |
| 9          | -90         | 2.58        | 2.58         | 2.58       | 0           |
| -100       | 10          | -5.8        | -5.8         | -5.8       | -90         |
+------------+-------------+-------------+--------------+------------+-------------+

Calculate the square of each value in the BIGINT, DOUBLE, DECIMAL, and STRING columns:

SELECT
    pow(bigint_data,  2) AS bigint_new,
    pow(double_data,  2) AS double_new,
    pow(decimal_data, 2) AS decimal_new,
    pow(string_data,  2) AS string_new
FROM mf_math_fun_t;

Result:

+------------+----------------------+----------------------+------------+
| bigint_new | double_new           | decimal_new          | string_new |
+------------+----------------------+----------------------+------------+
| 100.0      | 0.275625             | 0.275625             | 100.0      |
| NULL       | 0.010000000000000002 | 0.010000000000000002 | 100.0      |
| 1.0        | NULL                 | 418.2025             | 900.0      |
| 16.0       | 0.7921               | NULL                 | 900.0      |
| 2500.0     | 1.0                  | 1.0                  | 2500.0     |
| 36.0       | 2.25                 | 2.25                 | 2500.0     |
| 4900.0     | 56.25                | 56.25                | NULL       |
| 1.0        | 104.03999999999999   | 104.03999999999999   | 1.0        |
| 8100.0     | 6.6564000000000005   | 6.6564000000000005   | 0.0        |
| 100.0      | 33.64                | 33.64                | 8100.0     |
+------------+----------------------+----------------------+------------+

STRING and BIGINT inputs are returned as DOUBLE (shown in the bigint_new and string_new columns). A null input in any column produces a null output.

Related functions

pow is a mathematical function. For the full list of related functions, see Mathematical functions.