In order to get Absolute value of column in PostgreSQL we use abs() function. abs() function in PostgreSQL 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 PostgreSQL gets the absolute value
SELECT ABS (-134.5) AS Absolute_Value SELECT ABS (134.5) AS Absolute_Value
So the Absolute value will be
Get Absolute value of column in PostgreSQL table:
We use table States:
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