Skip to main content

POW

Description​

Returns the value of the first argument raised to the power of the second argument.

Alias​

  • POWER
  • FPOW
  • DPOW

Syntax​

POW(<a>, <b>)

Parameters​

ParameterDescription
<a>Base
<b>Power

Return value​

Return an integer type or a floating-point type.

Special cases:

  • If a IS NULL or b IS NULL, return NULL.
  • If b = 0 and a IS NOT NULL, it will always return 1.

Examples​

select pow(2, 0);
+-------------------------------------------+
| pow(cast(2 as DOUBLE), cast(0 as DOUBLE)) |
+-------------------------------------------+
| 1 |
+-------------------------------------------+
select pow(2, 10);
+--------------------------------------------+
| pow(cast(2 as DOUBLE), cast(10 as DOUBLE)) |
+--------------------------------------------+
| 1024 |
+--------------------------------------------+
select pow(1.2, 2);
+---------------------------------------------+
| pow(cast(1.2 as DOUBLE), cast(2 as DOUBLE)) |
+---------------------------------------------+
| 1.44 |
+---------------------------------------------+
select pow(1.2, 2.1);
+-----------------------------------------------+
| pow(cast(1.2 as DOUBLE), cast(2.1 as DOUBLE)) |
+-----------------------------------------------+
| 1.4664951016517147 |
+-----------------------------------------------+
select pow(2, null);
+------------------------------+
| pow(cast(2 as DOUBLE), NULL) |
+------------------------------+
| NULL |
+------------------------------+
select pow(null, 2);
+------------------------------+
| pow(NULL, cast(2 as DOUBLE)) |
+------------------------------+
| NULL |
+------------------------------+