POW

POW is a mathematical function in SQL that returns the power of a number. It calculates the value of a number raised to the power of another number.

POW(X,Y);

  • x: The base number that will be raised to the power of Y. This can be any numeric constant, variable, or expression.
  • y: The exponent to which the base number X is raised. This can also be any numeric constant, variable, or expression.

Example

SELECT POW(5, 3);

Output

125

Explanation

The available function POW(base, exponent) returns the value of the base argument raised to the power of the exponent argument. In this case, it’s calculating 5 to the power of 3, which equals 125.

POW( float_expression , y )

  • float_expression: A floating point number which serves as the base for the power function.
  • y: A floating point number representing the exponent to which the base number is raised.

Example

SELECT POW(2, 3) AS Result;

Output

Result
8

Explanation

The POW function in SQL returns the value of a number raised to certain power. In the given example, the number 2 is raised to the power of 3, returning the result 8.

POW(n number, m number) RETURN number;

  • n number: This is the base number. It signifies the number that will be raised to the power of another number.
  • m number: This is the exponent number. It shows the degree to which the base number will be raised.
  • return number: This is the output of the function. It signifies the result obtained after raising the base number to the power of the exponent number.

Example

SELECT POW(3, 4)
FROM dual;

Output

81

Explanation

In this example, the POW function raises the number 3 to the power of 4. When executed, it returns the result 81.

POW(x, y)

  • x: This is the base number. It is the value that is to be raised to a certain power. x can be any real number.
  • y: This is the exponent. It’s the number that determines how many times the base will be multiplied by itself. y can also be any real number.

Example

SELECT POW(2,3);

Output

8.0

Explanation

The above SQL command calculates the power of a number. The function POW(2,3) returns 2 to the power of 3, which equals 8.0 in SQLite.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.