POWER function - Amazon Redshift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

# POWER function

The POWER function is an exponential function that raises a numeric expression to the power of a second numeric expression. For example, 2 to the third power is calculated as `POWER(2,3)`, with a result of `8`.

## Syntax

``{POW | POWER}(expression1, expression2)``

## Arguments

expression1

Numeric expression to be raised. Must be an `INTEGER`, `DECIMAL`, or `FLOAT` data type.

expression2

Power to raise expression1. Must be an `INTEGER`, `DECIMAL`, or `FLOAT` data type.

## Return type

`DOUBLE PRECISION`

## Examples

The following examples use the TICKIT sample database. For more information, see Sample database.

In the following example, the POWER function is used to forecast what ticket sales will look like in the next 10 years, based on the number of tickets sold in 2008 (the result of the subquery). The growth rate is set at 7% per year in this example.

``````SELECT (SELECT SUM(qtysold) FROM sales, date
WHERE sales.dateid=date.dateid
AND year=2008) * POW((1+7::FLOAT/100),10) qty2010;

+-------------------+
|      qty2010      |
+-------------------+
| 679353.7540885945 |
+-------------------+``````

The following example is a variation on the previous example, with the growth rate at 7% per year but the interval is set to months (120 months over 10 years).

``````SELECT (SELECT SUM(qtysold) FROM sales, date
WHERE sales.dateid=date.dateid
AND year=2008) * POW((1+7::FLOAT/100/12),120) qty2010;

+-----------------+
|     qty2010     |
+-----------------+
| 694034.54678046 |
+-----------------+``````