PostgreSQL negate a numeric value in resultset

2.7k Views Asked by At

I have a query to return a resultset of decimal(30,12) type data.

SELECT sales from invoice_index;

This query is giving me output like this:

sales
------
100
-200
300

But I need an output as follow:

sales
----
-100
200
-300
1

There are 1 best solutions below

0
On BEST ANSWER

To negate a value, just multiply it with -1.

SELECT sales * (-1) from invoice_index;