Get Square of column in Postgresql

In order to get square of column in postgresql we use POWER() function. POWER() function in posgresql gets the square of the column. Let’s see how to

  • Get square value in postgresql
  • Create the column which extracts the square from another column

With an example for both

Get Square in Postgresql:

POWER() function in posgresql gets the square value

SELECT POWER(9,2) AS "Square";

So the square will be

Square of column in postgresql 2

 

Get Square of column in Postgresql table:

We use table student_details

Square of column in postgresql 1

SELECT *,POWER(gradscore,2) AS square_gradscore FROM student_detail;

We have created a column and stored square of gradscore column.

So the resultant table will be

Square of column in postgresql 3