Switch the Sign of a Number

Posted March 8, 2019 by Jim Knicely, Vertica Principal Solution Architect

Business Team Meeting Discussion Working Concept
To switch the sign of a number you can multiply it by -1.

Example: dbadmin=> SELECT col1, -1 * col1 col1_sign_switch dbadmin-> FROM test; col1 | col1_sign_switch ------+------------------ 10 | -10 -10 | 10 3 | -3 -3 | 3 (4 rows) Or you can use the Vertica built-in function NUMERIC_UM to do it for you! dbadmin=> SELECT col1, NUMERIC_UM(col1) col1_sign_switch dbadmin-> FROM test; col1 | col1_sign_switch ------+------------------ 10 | -10 -10 | 10 3 | -3 -3 | 3 (4 rows)