Summary: in this tutorial, you will learn how to use the SQLite power() function to raise a number to a specific power.
Introduction to SQLite power() function #
The power() function allows you to raise a number to a specific power.
Here’s the syntax of the power() function:
power(base, exponent)
In this syntax:
base: is the base number.exponent: is the exponent you want to raise the base number.
The power() function returns the base raised to the power exponent. It returns NULL if either base or exponent is NULL.
Please note that the power() and pow() function are synonyms, therefore, you can use them interchangeably.
SQLite power() function examples #
Let’s explore some examples of using the power() function.
1) Basic power() function examples #
The following statement uses the power() function to raise the number 2 to the power of 3:
SELECT power(2,3) result;
Output:
result
------
8.0
Likewise, you can use the power() function with decimal numbers:
SELECT power(2.5, 3) result;
Output:
result
------
15.625
2) Using the power() function with decimal exponents #
The following example uses the power() function to raise the number 1.5 to the power of 2.5:
SELECT power(1.5, 2.5) result;
Output:
result
------------------
2.7556759606310752
Please note that the return value is approximate, but not accurate.
Summary #
- Use the
power()function to raise a number to a specific power.
Thank you for your feedback!