In order to find raised to the power n in PostgreSQL we use POWER() function. This function is useful for mathematical calculations where you need to exponentiate values. POWER() function in PostgreSQL gets value raised to the power n. Let’s see how to
- Get value raised to the power n in PostgreSQL
- Create the column which extracts the raised power of another column
With an example for both
Syntax:
POWER(base, exponent)
- base: The number to be raised.
- exponent: The power to which the base number is raised.
Get value raised to the power n in PostgreSQL:
POWER() function in PostgreSQL gets the value raised to the power
SELECT POWER(3,2) AS square Select POWER(3,3) AS cube
So, the raised power 2 will be
Raised power 3 will be
Get raised power of column in PostgreSQL table:
We use table student_details
SELECT *,POWER(gradscore,4) AS power4_gradscore FROM student_detail;
We have created a column and stored power four of gradscore column.
So the resultant table will be