I have a column with some zeros. If this column is NULL, I want to set the output for it based on the values in another column.
So if case when null (if c=80 then 'planb'; else if c=90 then 'planc')
if case when null (if c=80 then 'planb'; else if c=90 then 'planc')
How would you code this in the T-SQL built-in statement?
thank.
COALESCE(YourColumn, CASE c WHEN 80 then 'planb' WHEN 90 THEN 'planc' END)
You can also use the nested case statement. Assuming the first column is called a DataColumn.
CASE WHEN DataColumn IS NULL THEN CASE c WHEN 80 THEN 'planb' WHEN 90 THEN 'planc' ELSE 'no plan' END ELSE DataColumn END