Maybe something like this:
SELECT
EID,
Name,
(
CASE
WHEN NOT changed_id IS NULL OR NOT changed_id = 'NULL'
THEN 'Y'
ELSE 'N'
END
)AS FLAG
FROM
EMPLOYEE
Update
To answer the comment. We need to check for both IS NULL
and = 'NULL'
. Because of the reason that NULL!='NULL'
. NULL
will never be equals the string value of 'NULL'
.
I would suggest that the OP checks where actuality (s)he insert or update so that the value of the column becomes the string 'NULL'
and make sure that it is NULL
. Then the OP doesn't need to check for both cases.
Update #2:
For people new to the subject, a good way to remember what null means
is to remember that in terms of information, "lack of a value" is not
the same thing as "a value of zero"; similarly, "lack of an answer" is
not the same thing as "an answer of no". For example, consider the
question "How many books does Juan own?" The answer may be "zero" (we
know that he owns none) or "null" (we do not know how many he owns, or
doesn't own). In a database table, the column reporting this answer
would start out with a value of null, and it would not be updated with
"zero" until we have ascertained that Juan owns no books.
Reference: