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 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