SQL POWER()

nikolaspoczekaj's avatar
Published May 23, 2023
Contribute to Docs

The POWER() function in SQL is a mathematical function that returns the value of a number raised to the power of another number. It is compatible with various SQL database systems such as MySQL, PostgreSQL, Oracle, and SQL Server.

  • Learn to analyze data with SQL and prepare for technical interviews.
    • Includes 9 Courses
    • With Certificate
    • Beginner Friendly.
      18 hours
  • In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
    • Beginner Friendly.
      5 hours

Syntax

SELECT POWER(base, exponent)
FROM table_name;

Example

In this example the following data is given in the table numbers:

base_number exp_number
3 2
5 3
7 0

The POWER() function can be used to calculate the result:

SELECT base_number, exp_number, POWER(base_number, exp_number) AS power_number
FROM numbers;

The output will be:

base_number exp_number power_number
3 2 9
5 3 125
7 0 1

All contributors

Contribute to Docs

Learn SQL on Codecademy

  • Learn to analyze data with SQL and prepare for technical interviews.
    • Includes 9 Courses
    • With Certificate
    • Beginner Friendly.
      18 hours
  • In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
    • Beginner Friendly.
      5 hours