Ploughansen
Ploughansen

Reputation: 313

Convert positive numbers to negative and vice verca in select statement

In my table, positive numbers are stored as negatives and vice versa. This makes sense from an accounting point of view, however, I would like to make a select statement that returns the numbers reversed.

Example as stored in db:

YEAR   MONTH   REVENUE
-------------------------
2017   12      -12000,00
2017   11       -1500,00
2017   10       30000,00

This tells me that there was a surplus in December 2017 and a deficit in November and October.

Is there a function that does this or do I need some more advanced SQL wizardry?

Disclaimer: I understand this question might have been asked several times before. I am asking again because I am looking for a more simplified answer (if possible?)

Upvotes: 2

Views: 8555

Answers (1)

A. van Esveld
A. van Esveld

Reputation: 258

As stated in comment multiply by -1

Select
Year,
Month,
Revenue * -1 as Revenue
From Table

Upvotes: 6

Related Questions