Reputation: 5242
I am trying to write a query which checks if 2 amounts have the same sign (+ or -). Do you have a good solutions that can be used?
Something like: If SAMESIGN(value1, value2) then do something
Upvotes: 7
Views: 38427
Reputation: 25753
Try to use sign function as below
case
when sign(value1)=sign(value2) then 'the same sign'
else 'different sign'
end
Upvotes: 11
Reputation: 18411
CASE WHEN (value1 * value2) < 0 THEN 'DiffSign' ELSE 'SameSignOrOneIsZero' END
Upvotes: 14