Chris Chris - 12 days ago 7
SQL Question

If column data is null or contains an empty string then 'N/A'

I have a column called County, and in this column sometimes there is a county and other times its either empty or contains NULL. So far I am able to change it when there is an empty string to N/A, but not sure how to change it if there is a NULL as well.
So far I am using a case statement to check if the column contains an empty string

case County when '' then 'N/A' end


but I need to check if the column data is NULL as well and change it to N/A.

So in short, if any data in the County column is an empty string or is NULL then I need to add N/A.

Answer
case when County = '' or County is null
     then 'N/A' 
     else County 
end
Comments