In this PostgreSQL post explains how to use the PostgreSQL abs function with syntax and examples.
The PostgreSQL abs function returns the absolute value of a number.
The syntax for the abs function in PostgreSQL is:
abs( number )The number to convert to an absolute value.
The abs function can be used in the following versions of PostgreSQL:
Let's look at some PostgreSQL abs function examples and explore how to use the abs function in PostgreSQL.
For example:
postgres=# SELECT abs(-23);
 abs
-----
  23
(1 row)
postgres=# SELECT abs(-23.6);
 abs
------
 23.6
(1 row)
postgres=# SELECT abs(-23.65);
  abs
-------
 23.65
(1 row)
postgres=# SELECT abs(23.65);
  abs
-------
 23.65
(1 row)
postgres=# SELECT abs(30 * -1);
 abs
-----
  30
(1 row)