Get Absolute value of column in Postgresql

In order to get Absolute value of column in postgresql we use abs() function. abs() function in posgresql gets the absolute value of the column. Let’s see how to

  • Extract absolute value in postgresql
  • Create the column which extracts the absolute value from another column

With an example for both

Get Absolute value in Postgresql:

abs() function in posgresql gets the absolute value

SELECT ABS (-113.5) AS “Absolute Value”
SELECT ABS (113.5) AS “Absolute Value”

So the Absolute value will be

Get Absolute value of column in postgresql 2

 

Get Absolute value of column in Postgresql table:

We use table States:

Get Absolute value of column in postgresql 1

SELECT *,ABS(hindex_score) AS absolute_hindex FROM States

We have created a column and stored absolute value from hindex_score column.

So the resultant table will be

Get Absolute value of column in postgresql 3

 

                                                                                                 

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.