Raised to the power n in Postgresql – Power() Function

In order to find raised to the power n in postgresql we use POWER() function. POWER() function in posgresql 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

Get value raised to the power n in postgresql:

POWER() function in posgresql 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 to the power n in Postgresql 2

Raised power 3 will be

Raised to the power n in Postgresql 3

 

Get raised power of column in Postgresql table:

We use table student_details

Raised to the power n in Postgresql 1


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

Raised to the power n in Postgresql 4

 

                                                                                                       

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.