SIGN
Return the sign of a number:
0
= the number is 0.1
= the number is a positive number-1
= the number is a negative number
SIGN(number)
For example:
premdb=# SELECT SIGN(-52.3);
sign
------
-1
(1 row)
The following example finds the sign of the result of an expression.
premdb=# SELECT ftscore,
SIGN((SUBSTR(ftscore,1,1)::INT)-(SUBSTR(ftscore,3,1)::INT))
FROM match LIMIT 25;
ftscore | sign
---------+------
0-1 | -1
0-1 | -1
2-1 | 1
3-0 | 1
3-0 | 1
2-0 | 1
0-0 | 0
0-0 | 0
0-1 | -1
1-0 | 1
0-1 | -1
1-1 | 0
2-4 | -1
...
Parent topic:Mathematical Functions