0

In this example, where Field1 - Field2 can equal 0 and will, how to I add another condition so that it continues with evaluating the conditions to compute the THEN when Field1 - Field2 does not equal zero?

CASE 

WHEN  (100 * ((Field1 - Field2) / Field1)) = X) OR
WHEN  (100 * ((Field1 - Field2) / Field1)) = Y) OR
WHEN  (100 * ((Field1 - Field2) / Field1)) = Z)
THEN (Field1*1.05)
END AS 'FIELD3'

Cheers

Jeff 36
  • 1
  • 1
  • 2
    Why is `Field1 - Field2` equaling zero a problem? Isn't `Field1` being zero the bigger problem? – Tim Biegeleisen Aug 26 '15 at 06:50
  • 1
    Add WHEN FIELD1 = 0 THEN first in your CASE. – jarlh Aug 26 '15 at 06:50
  • 1
    I would use something like `ISNULL(NULLIF(Field1, 0), 1)` to avoid the Divide by zero error, but it really depend on your business logic. – Franky Aug 26 '15 at 06:58
  • 1
    This question is a bit unclear, at least to me. Can you share some sample data and the result you're trying to get for that data? – Mureinik Aug 26 '15 at 07:03

1 Answers1

0

I'm terribly sorry for wasting you're time everyone, this is embarrassing I missed an obvious WHERE condition, and got a little flustered. Appreciate you all responded so quickly.

Cheers

Jeff 36
  • 1
  • 1