Nia Nia - 5 months ago 8x
SQL Question

Negating an integer which sql query returned

I have a SQL sub query,

SELECT `generateoffset` FROM `opa`.`sddrecurrencetype` WHERE `sddrecurrencetypeid`=1;

it returns as a result

What I am wondering is that, if its possible to get negative of what the value is returned from the query.

I tried to do it like this,

-(SELECT `generateoffset` FROM `opa`.`sddrecurrencetype` WHERE `sddrecurrencetypeid`=1)

I thought may be it will give me negative of what the result of the query would be like
, but alas its not working like this.

Can some one please tell me , if its possible what I am trying to do.

Thanks in Advance!!!


Just multiply the column result rather than the entire query:

SELECT `generateoffset` * -1 as 'generateoffset' 
FROM `opa`.`sddrecurrencetype` 
WHERE `sddrecurrencetypeid`=1;