I have a column C1 whose value can be 'values', 'empty' or 'N/A'.
| C1 | ------- | | | N/A | |apple|
I want to select column C1 in a way that converts null values and N/A to NULL, using NULLIF.
| C1 | ------- |NULL | |NULL | |apple|
We can use NULLIF(C1, '')
, which returns NULL if the column value is empty.
We can also use CASE to achieve these two situations, but I want to know if there is a way to use NULLIF to achieve it, and if so, how to achieve it? (Or other methods besides CASE)
Similar to NULLIF(C1, '' OR 'N/A')
Thanks in advance.
Use
case
Expression:You can use nested
NULLIF()
functions to achieve:SeeDemo.