Reputation: 3129
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.
Upvotes: 0
Views: 3757
Reputation: 204884
case when County = '' or County is null
then 'N/A'
else County
end
Upvotes: 1
Reputation: 453648
One way would be
Case when County <> '' then County ELSE 'N/A' end
Both nulls and empty strings end up at the else.
Upvotes: 3