I currently have a query on the following form:
SELECT
CASE
WHEN <column> IS NOT NULL THEN <expression>
ELSE NULL
AS <new_column>,
CASE
WHEN <other_column> IS NOT NULL THEN <other_expression>
ELSE NULL
AS <new_other_column>,
-- etc...
I'm thinking that it must be possible to rewrite the CASE
statements as something that's easier to read, with less boilerplate.
I could do it with an IIF
:
IIF(<column> IS NOT NULL, <expression>, NULL) AS <new_column>
but that still leaves both IS NOT NULL
and NULL
there.
Is there some construct FOO
that would let me say
FOO(<nullcheck_expression>, <result_expression>)
and have that return the same thing as IIF(<nullcheck_expression> IS NOT NULL, <result_expression>, NULL)
?