Skip to content
Advertisement

Convert positive data into negetive data (entire column) in Postgres Server

The current data in my table is:

  a   b
---------  
 -1   5
 -11  2   
 -5  32

My request is to convert every data of column a into negative value.

But how to update the positive values into the negative selecting the entire column?

Advertisement

Answer

Try this:

 Update table set a= 0-a where a >0
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement