(ISNULL([Deal Status]) ? "2" : SUBSTRING([Deal Status],1,1)) == "2"
When using the
? and :, it's a conditional operator, the same as using an if/else statement:
condition ? true result : false result
So to breakdown what your statement is doing, it first checks to see if
DealStatus IS NULL. If so, it returns a "2". If it isn't
NULL, it returns the first character of the
DealStatus field using
SUBSTRING. Finally, it compares that result to see if it's equal to "2".
The overall expression will return a true/false. For example, if
NULL, this will always return true.
For example, here would be the results if the following values were stored in the DealStatus field.
DealStatus ResultOfCondition NULL true (because DealStatus is NULL, we compare 2 == 2 is true) 123 false (because the first character is 1, 1 == 2 is false) 234 true (because the first character is 2, 2 == 2 is true)