In this PostgreSQL post explains how to use the PostgreSQL sign function with syntax and examples.
The PostgreSQL sign function returns a value indicating the sign of a number.
The syntax for the sign function in PostgreSQL is:
sign( number )
The number to test for its sign.
The sign function can be used in the following versions of PostgreSQL:
Let's look at some PostgreSQL sign function examples and explore how to use the sign function in PostgreSQL.
For example:
postgres=# SELECT sign(12);
sign
------
1
(1 row)
postgres=# SELECT sign(0);
sign
------
0
(1 row)
postgres=# SELECT sign(-12);
sign
------
-1
(1 row)